seam-gen doesn't generate EntityQuery interfaces for @ManyToMany members

£可爱£侵袭症+ 提交于 2019-12-23 21:40:35

问题


@org.jboss.seam.annotations.security.management.UserRoles exposed in the User interface returns a simple List method.

seam-gen doesn't generate EntityQuery interfaces for @ManyToMany members like the getUserRoles mentioned above.

How do we enable this, so that the resultant roles are shown in a paginated fashion.

Edit 1:

This is the declaration in User.java

@ManyToMany(cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}, fetch = FetchType.LAZY)
@JoinTable(name = "user_role", joinColumns = @JoinColumn(name = "user_id), inverseJoinColumns = @JoinColumn(name = "role_id"))
@UserRoles
private List<Role> userRoles = new ArrayList<Role>(0);

This is the declaration in Role.java

@Entity
@Table(name = "role", uniqueConstraints = @UniqueConstraint(columnNames = "name"))
public class Role {

回答1:


As said by Pete Muir, Seam lead developer

Seam-gen does not support @ManyToMany relationship

It does not generate the User Interface when using @ManyToMany. Although Seam-gen makes your life easier, sometimes, you have to do your job manually.

Before going on

  1. Seam-gen uses Hibernate's reverse-engineering-tool
  2. If a foreign key is missing in the table, Seam-gen can not suppose one table is related to another

...

So my advice is:

  1. Split your @ManyToMany relationship into @OneToMany - @ManyToOne relationship
  2. Set up reverse-engineering configuration

The reverse-engineering configuration file that Seam-gen uses is resources/seam-gen.reveng.xml inside the generated project.

Maybe you want to see

Controlling reverse engineering

Reverse engineering support in database and drivers

Added to original answer

Seam uses Ant to generate your app. Its build.xml file is located in the <SEAM_HOME>/seam-gen/build.xml

There, you will see a target called generate-ui as follows

<target name="generate-ui"

It uses a Ant Tool called hbmtemplate. It is a Template based Engine in which can be controlled by a user provided template or class. So if you want a custom behavior, you should provide your own Freemarker template. In <SEAM_HOME>/seam-gen/view directory, you can see a lot of Template files (.flt extension)

regards,



来源:https://stackoverflow.com/questions/2073199/seam-gen-doesnt-generate-entityquery-interfaces-for-manytomany-members

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!