Forget about it. Solved. One of those stupid mistakes:

It was a case problem, all I had to do was to change the private
Set<String> sAuthorities to private Set<String> sauthorities and then
update the proper setter and getter.

I have tried the caseSensitive=false on the annotation before to no effect,
which is why I sent the email.

Nonetheless, here is the answer to it in case someone got stuck on the
issue.

On Sat, Sep 20, 2014 at 9:28 PM, Carlos Scheidecker <nando....@gmail.com>
wrote:

> 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 {
>
> @Transient
> private static final long serialVersionUID = 1L;
>
> @PartitionKey
> @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>();
>  @Transient
> @FrozenValue
> 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);
> this.authorities.add(auxAuthor);
> }
> }
>
> @Override
> 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) {
> this.sAuthorities.add(a.getAuthority());
> }
> }
>
>
> 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.ReflectionMapper$ReflectionFactory.createColumnMapper(ReflectionMapper.java:375)
> at
> com.datastax.driver.mapping.AnnotationParser.convert(AnnotationParser.java:148)
> at
> com.datastax.driver.mapping.AnnotationParser.parseEntity(AnnotationParser.java:100)
> at
> com.datastax.driver.mapping.MappingManager.getMapper(MappingManager.java:119)
> at
> com.datastax.driver.mapping.MappingManager.mapper(MappingManager.java:76)
>
> 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);
> mapper.save(principal);
>
> 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?
>
> Thanks.
>

Reply via email to