Hate to answer my own question, but I think the proper relation for:

@OneToMany
@Cascade(CascadeType.ALL)
 public Collection<GrantedAuthorityBean> getGrantedAuthorities() {
        return grantedAuthorities;
}

is:

@ManyToMany( cascade={CascadeType.PERSIST, CascadeType.MERGE} )

You then need to persist your GrantedAuthorityBean independently from UserDetails, but that makes sense, and it solves the problem of the GrantedAuthorityBean and the join table exploding with duplicate info.

Thanks,

J

PS. http://www.localhost.nu/svn/public/tapestry5-acegi-example/src/ main/java/nu/localhost/tapestry/acegi/example/entities/ UserDetailsBean.java



On 10-Mar-08, at 5:18 PM, Julian Wood wrote:

In the provided example for tapestry-acegi, I have a question about the GrantedAuthorityBean table. That is, if I add more users which share roles, each role will create a new row in the GAB table. How can this be avoided?

I've tried making the authority unique:

@Table(uniqueConstraints = [EMAIL PROTECTED](columnNames = {"authority"})})

but hibernate is not clever enough to realize that it should reuse existing roles, and just throws a constraint exception. I'm looking at interceptors now. I guess this is really a hibernate question, but I thought that someone here might have encountered this issue, given its context in tapestry-hibernate.

Thanks,

J

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to