[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - ManyToMany, sort by field in mapping table

dkane do-not-reply at jboss.com
Tue Dec 25 06:55:27 EST 2007


Dear colleagues, 

I have Termnal and Firmware entities , with Terminal_Firmware table that defines many-to-many relationship. 
Terminal has a collection of bound Firmwares : 

@ManyToMany(cascade = {CascadeType.PERSIST})
  | @JoinTable(
  | name="Terminal_Firmware", 
  | joinColumns=@JoinColumn(name="tId",  referencedColumnName="tId"),
  | inverseJoinColumns=@JoinColumn(name="fId", referencedColumnName="Id")
  | )			
  | 
  | public List<Firmware> getFirmwares()
  | {
  | 	return firmwares;
  | }


Terminal_Firmware also contains integer column "position", which I want firmwares to be sorted by. 

Problem can be solved by adding a separate entity for Terminal_Firmware and making a query to all 3 tables, but I'd like to avoid that . 

@OrderBy annotation does not work for fields in mapping table. 

Do you know the way ? 
Many thanks in advance. 

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

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



More information about the jboss-user mailing list