我在整个应用程序中都使用spring CrudRepository
。
现在,我还想为没有@Entity
的@Id
创建一个。那有可能吗?
//probably ID is always required?
public interface Repository<T, ID extends Serializable>
最佳答案
JPA要求每个实体都有一个ID。因此,不可以,没有ID的实体是不允许的。
来自JPA spec
您可能需要阅读更多有关JPA如何处理数据库端from here (see 'No Primary Key')上没有id的情况的信息。