Hibernate JPA 2 元模型生成器在与 Spring Roo 一起使用时忽略字段
我想通过 Hibernate JPA 2 元模型生成器为 Spring Roo 实体创建 JPA 2 元模型。
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>1.1.1.Final</version>
我按照 http:// docs.jboss.org/hibernate/jpamodelgen/1.1/reference/en-US/html_single/。 我还向 Roo 管理的实体添加了 @Entity 注释,生成器创建 Metamodell 类,但它使用 Metamodel 的 Getter,而不是字段。
例如我的实体:
@RooJavaBean
@RooToString
@Entity
public class Banner {
@PersistenceContext
private transient EntityManager em;
private String name;
private int code;
private Champaign champaign;
public String getChampaignName() {
return this.champaign.getName();
}
}
对于这个实体,它创建元模型:
@StaticMetamodel(Banner.class)
public abstract class Banner_ {
public static volatile SingularAttribute<Banner, String> champaignName;
}
在非 Roo 项目中,相同的设置工作正常。
是否有任何配置可以指定生成器基于字段而不是 Getter,以便元模型描述字段:{{name}} {{code}} {{chhampaign}}。
I want to create a JPA 2 Metamodel by Hibernate JPA 2 Metamodel Generator for Spring Roo Entities.
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>1.1.1.Final</version>
I get the process working in the way described at http://docs.jboss.org/hibernate/jpamodelgen/1.1/reference/en-US/html_single/.
I also have added the @Entity Annotation to the Roo managed Entities and the generator create the Metamodell classes, but instead of the fields, it uses the Getter for the Metamodel.
For example my Entity:
@RooJavaBean
@RooToString
@Entity
public class Banner {
@PersistenceContext
private transient EntityManager em;
private String name;
private int code;
private Champaign champaign;
public String getChampaignName() {
return this.champaign.getName();
}
}
For this entity it creates the Metamodel:
@StaticMetamodel(Banner.class)
public abstract class Banner_ {
public static volatile SingularAttribute<Banner, String> champaignName;
}
In a not Roo Project the same settings works fine.
Is there any configuration that where I can specify that the generator is based on the fields and not on the Getter so that the Meta Model describe the fields: {{name}} {{code}} {{champaign}}.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种解决方法是使用
@Access(AccessType.FIELD) 注释/所有实体
One workaround is to annotate the/all Entities with
@Access(AccessType.FIELD)