本文介绍了seam-gen 不会为 @ManyToMany 成员生成 EntityQuery 接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

@org.jboss.seam.annotations.security.management.UserRoles 在用户界面中公开,返回一个简单的 List 方法.

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

seam-gen 不会像上面提到的 getUserRoles 那样为 @ManyToMany 成员生成 EntityQuery 接口.

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.

编辑 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);

这是Role.java中的声明

This is the declaration in Role.java

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

推荐答案

正如 Seam 首席开发人员 Pete Muir 所说

As said by Pete Muir, Seam lead developer

Seam-gen 不支持@ManyToMany 关系

使用@ManyToMany 时不会生成用户界面.尽管 Seam-gen 让您的生活更轻松,但有时您必须手动完成工作.

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.

在继续之前

  1. Seam-gen 使用 Hibernate 的逆向工程工具
  2. 如果表中缺少外键,Seam-gen 不能假设一个表与另一个表相关
  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

...

所以我的建议是:

  1. 将您的@ManyToMany 关系拆分为@OneToMany - @ManyToOne 关系
  2. 设置逆向工程配置

Seam-gen 使用的逆向工程配置文件是生成的项目中的 resources/seam-gen.reveng.xml.

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

也许你想看

控制逆向工程

数据库和驱动程序中的逆向工程支持

添加到原始答案

Seam 使用 Ant 生成您的应用程序.它的 build.xml 文件位于 /seam-gen/build.xml

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

在那里,您将看到一个名为 generate-ui 的目标,如下所示

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

<target name="generate-ui"

它使用名为 hbmtemplate.它是一个基于模板的引擎,其中可以由用户提供的模板或类进行控制.因此,如果您想要自定义行为,您应该提供您自己的 Freemarker 模板.在<SEAM_HOME>/seam-gen/view目录下,可以看到很多Template文件(.flt扩展名)

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)

问候,

这篇关于seam-gen 不会为 @ManyToMany 成员生成 EntityQuery 接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 17:45