简体   繁体   中英

Hibernate JPA 2 Metamodel Generator ignore fields when uses with Spring Roo

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}}.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM