cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carlos Scheidecker <>
Subject How to map a set<text> field?
Date Sun, 21 Sep 2014 03:28:10 GMT
Hello all,

I have the following table:

CREATE TABLE userprincipal (
  userid timeuuid,
  username varchar,
  hashedpassword blob,
  authorities set<text>,
  accountnonexpired boolean,
  accountnonlocked boolean,
  credentialsnonexpired boolean,
  enabled boolean,
  PRIMARY KEY(username)

Now, I have an UserPrincipalObject to which Authorities ia a HashSet of
UserAuthority Spring objects. If the system does the setting through that
object, I update my own set of Strings called sAuthorities.

On the database I save the sAuthorities which is what I map. But on the
object on the memory I mape the set of UserAuthorities

My UserPrincipalObject is as follows:

@Table(name = "userprincipal")
public class UserPrincipal implements UserDetails, CredentialsContainer,
Cloneable {

private static final long serialVersionUID = 1L;

@Column(name = "username")
private String userName;

@Column(name = "userid")
private UUID userID;

@Column(name = "hashedpassword")
private ByteBuffer hashedPassword;

@Column(name = "sauthorities")
private Set<String> sAuthorities = new HashSet<String>();
Set<UserAuthority> authorities = new HashSet<UserAuthority>();

@Column(name = "accountnonexpired")
private boolean accountNonExpired;

@Column(name = "accountnonlocked")
private boolean accountNonLocked;

@Column(name = "credentialsnonexpired")
private boolean credentialsNonExpired;

@Column(name = "enabled")
private boolean enabled;

The setters for both Authorities list is as follows:

Now, note that the set for sAuthorities updates the authorities variable
which is a Set<UserAuthority>

And that the set for authorities updates the Set<String> sAuthority with is
what gets persisted to the table.

So  @Column(name = "sauthorities")
private Set<String> sAuthorities = new HashSet<String>();

Also authorities is @Transient annotated.

public Set<String> getsAuthorities() {
return sAuthorities;

public void setsAuthorities(Set<String> sAuthorities) {
this.sAuthorities = sAuthorities;
this.authorities = new HashSet<UserAuthority>();
UserAuthority auxAuthor;
for (String a : sAuthorities) {
auxAuthor = new UserAuthority(a);

public Set<UserAuthority> getAuthorities() {
return this.authorities;

public void setAuthorities(Set<UserAuthority> authorities) {
this.authorities = authorities;
this.sAuthorities = new HashSet<String>();
for (UserAuthority a : this.authorities) {

However, when I create the mapper I get the following error:

Exception in thread "main" java.lang.IllegalArgumentException: Cannot find
matching getter and setter for field 'sAuthorities'
at com.datastax.driver.mapping.MappingManager.mapper(

Now, note that sAuthorities is properly annotated:

@Column(name = "sauthorities")
private Set<String> sAuthorities = new HashSet<String>();

My mapper code is as follows:

MappingManager manager = new MappingManager(session);
Mapper<UserPrincipal> mapper = manager.mapper(UserPrincipal.class);;

What is going wrong? Do I have to have a special annotation for Set<text>
 because I could not find one looking at the source code nor the manual.
Yes for UDTs you have that. Do I have to put that inside an UDT?


View raw message