我正在使用Spring Boot 1.4.0,用于存储层的Spring数据和用于JPA的Hibernate.
当我在不想保留的实体字段之一上使用org.springframework.data.annotation.Transientannotation时,它不起作用.
当我使用javax.persistence.Transient时,它按预期方式工作(每个注释都来自javax.persistence包).
我已经阅读了很多文档,但找不到原因.请帮助我了解区别,谢谢.
更新资料
从下面的评论和答案中,我将javax.persistence包中的@Id和@transient都更改为org.springframework.data.annotation,它仍然产生以下错误:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: No identifier specified for entity: com.xxx.domain.entities.PriceScheduleEntity
我想我需要将所有注释(包括@ Column,@ Entity等)更改为同一供应商/提供者/软件包,以使其正常工作. JPA和spring的注释不能混合吗?我会稍后尝试更新.
转载注明原文:org.springframework.data.annotation.Transient与javax.persistence.Transient - 乐贴网