[jboss-user] [JBoss Seam] - Re: seam-gen : reverse DB : many-to-many convention ?

damienhuriet do-not-reply at jboss.com
Wed Dec 19 02:56:31 EST 2007


Thanks for the reply, but it "seams" to do.
Indeed, I've managed to generate a many-to-many relationship with seam-gen between two tables NAME1 and NAME2:
The many-to-many relationship table should:
- its name should be "NAME1_NAME2"
- it has the right to have only 2 columns : a double primary key relying on the two foreignKey columns : FK1 and FK2 named as you want but with reference integrity constraints towards the primary key of the two tables : NAME1 and NAME2.

It has generated me the getters and setters of the list in each entity NAME1 and NAME2 : 

Expl : 

- The class NAME1 contains the function "public Set<NAME2> getName2s()" and its setter 


- The class NAME2 contains the function "public Set<NAME1> getName1s()" and its setter

and no entity has been generated for the table "NAME1_NAME2", that is right because it is a "utility table" and not a table reflecting a "business objet" to be persisted.

The hibernate relationship has been created also : 

  | @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
  | 	@JoinTable(name = "NAME1_NAME2", catalog = "mycatalogname", joinColumns = { @JoinColumn(name = "NAME1_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "NAME2_ID", nullable = false, updatable = false) })
  | 	public Set<Name2> getName2s() {
  | 		return this.name2s;
  | 	}
  | 	public void setName2s(Set<Name2> name2s) {
  | 		this.name2s = name2s;
  | 	}

I still have a problem in the following step : 

As the returned list is of type java.util.Set and not java.util.List, I do not (for the moment) manage to display this list in a rich:datatable : 

  |         <rich:dataTable var="name2s" 
  |                    value="#{name1Home.instance.name2s}" 
  |                 rendered="#{name1Home.instance.name2s != null}"
  |               rowClasses="rvgRowOne,rvgRowTwo"
  |                       id="name2sTable">
  |             <h:column>
  |                 <f:facet name="header">id</f:facet>
  |                 #{name2s.id}
  |             </h:column>

Caused by javax.servlet.ServletException with message: "/Name1Edit.xhtml: Property 'id' not found on type org.hibernate.collection.PersistentSet" 

Caused by javax.el.ELException with message: "/Name1Edit.xhtml: Property 'id' not found on type org.hibernate.collection.PersistentSet" 

If anyone can help me on this point.



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

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

More information about the jboss-user mailing list