You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Julian Wood <wo...@ucalgary.ca> on 2008/03/11 03:37:21 UTC

Re: tapestry-acegi example app question (solved)

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 = {@UniqueConstraint(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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: tapestry-acegi example app question (solved)

Posted by Robin Helgelin <lo...@gmail.com>.
On Tue, Mar 11, 2008 at 3:37 AM, Julian Wood <wo...@ucalgary.ca> wrote:
> Hate to answer my own question, but I think the proper relation for:
>
>  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! I'll update the example.

-- 
 regards,
 Robin

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org