简体   繁体   中英

JPA Metamodel Generator doesn't create all fields

This is my class:

@Embeddable
public class QuarterIntValues {
    @Column(nullable = true)
    private int valueRR;

    @Column(nullable = true)
    private int valueRL;

    @Column(nullable = true)
    private int valueFL;

    @Column(nullable = true)
    private int valueFR;
}

And this is the generated Metamodel:

@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
    @StaticMetamodel(QuarterIntValues.class)
    public abstract class QuarterIntValues_ {

    public static volatile SingularAttribute<QuarterIntValues, Integer> value;

}

I expected that the metamodel processor generates a field for every field that I created in the original class. Am I missing or misunderstanding something? Thanks for any help in advance.

I found the answer to my problem. You need to create getter and setter for the fields in your class. The metamodelProcessor generates the fields in the metamodel class then.

I had a similar problem but my issue was due to missing a generated Id in the entity class as in below:

@Id
@GeneratedValue
Integer xxx;

That fixed my issue.

As a new comer to JPA, seems like every entity table needs it?

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