I am having this super irritating issue with my hibernate/jpa app I'm developing using maven and editing in eclipse.
I have my target/metamodel location set up in Properties > compiler > annotation processing, and it's all working fine, except for one class, where the metamodel class only contains the id.
Here is the entity:
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private String username;
private String password;
@Transient
private Authorization authorization;
// getters/setters omitted, but I do have them in the entity class
}
and here is the metamodel class
@Generated(value="Dali", date="2019-06-22T11:49:45.797-0400")
@StaticMetamodel(User.class)
public class User_ {
public static volatile SingularAttribute<User, Integer> id;
}
This issue only occurs in the User class, all other classes are fine. I am getting compile errors in my DAO where I try to get a user with username/pw, and those fields do not exist in the metamodel class.
Any ideas what would cause this? Working on linux, compiler set to 1.8. thanks
I ended up solving it by adding an entry for the entity in persistence.xml
<class>com.mypack.model.User</class>
I had gone thru the process of creating the entity and doing crud save, update, delete, and get by id functions, without the persistence.xml entries. I think I started with a few, found I didn't need them and commented them out.
Seeing now that when I try to create a criteriabuilder/root/query, etc, I run into that issue. Adding the entity to persistence.xml seems to have resolved it.
I think it may be Dali generator's fault. I tried with hibernate-jpamodelgen through regular maven plugin and it works fine.
I suggest you do the same: it works, and everyone working on the project will benefit from it, you won't have to commit generated sources or tell everyone to configure Eclipse in the same way.
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</compilerArguments>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.4.3.Final</version>
</dependency>
</dependencies>
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.