JPA exception: Object: … is not a known entity type

后端 未结 11 648

I\'m new to JPA and I\'m having problems with the autogeneration of primary key values.

I have the following entity:

package jpatest.entities;

impor         


        
11条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-10 03:17

    I use this syntax rather than type AUTO

    @javax.persistence.Id
    @javax.persistence.GeneratedValue(strategy = GenerationType.IDENTITY)
    

    Then, I use the simple type "long" for ID's with a lowercase l :

    private long taskID;
    

    This may be unrelated, but I also specify a different table name for my entities:

    @javax.persistence.Entity(name = "Tasks")
    public class Task implements Serializable
    

提交回复
热议问题