[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Create index for an @ManyToMany / @JoinTable relation

literadix do-not-reply at jboss.com
Sat Nov 25 01:12:56 EST 2006


Hi there,

I am trying to create a database index for a mapping table. My source looks like this:


  | 	@ManyToMany(
  | 			targetEntity=PortalUser.class, 
  | 			cascade = { CascadeType.PERSIST, CascadeType.MERGE }, 
  | 			fetch = FetchType.LAZY
  | 		)
  | 	@JoinTable(
  | 			name="friends", 
  | 			joinColumns={@JoinColumn(name="psid")}, 
  | 			inverseJoinColumns={@JoinColumn(name="ptid")}, 
  | 			uniqueConstraints={@UniqueConstraint(columnNames={"psid", "ptid"})}
  | 		)
  | 

If I try to use the following code i get an error:


  | 	@ManyToMany(
  | 			targetEntity=PortalUser.class, 
  | 			cascade = { CascadeType.PERSIST, CascadeType.MERGE }, 
  | 			fetch = FetchType.LAZY
  | 		)
  | 	@JoinTable(
  | 			name="friends", 
  | 			joinColumns={@JoinColumn(name="psid")}, 
  | 			inverseJoinColumns={@JoinColumn(name="ptid")}, 
  | 			uniqueConstraints={@UniqueConstraint(columnNames={"psid", "ptid"})}
  | 		)
  | 	@Index(name = "friendindex", columnNames={"psid", "ptid"})
  | 

Does any one has a solution for this?

Thank you very much,

Maciej

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3988511#3988511

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3988511



More information about the jboss-user mailing list