Hibernate JPA 2 元模型生成器在与 Spring Roo 一起使用时忽略字段

发布于 2024-11-10 10:11:20 字数 1148 浏览 9 评论 0原文

我想通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回眸一笑 2024-11-17 10:11:20

一种解决方法是使用 @Access(AccessType.FIELD) 注释/所有实体

One workaround is to annotate the/all Entities with @Access(AccessType.FIELD)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文