[英]@Transient in spring data doesn't work
我有Settlement
實體
@Entity
@Table(name = "settlement")
public class Settlement {
@ManyToOne
@JoinColumn(name = "subscription_x_product_id")
private ProductSubscription productSubscription;
與ProductSubscription
實體相關
@Entity
@Table(name = "subscriptionproduct")
public class ProductSubscription {
@ManyToOne
@JoinColumn(name = "product_id")
private Product product;
與Product
實體相關
@Entity
public class Product {
@Transient
private String enabled;
在Product
實體中,我已enabled
使用@org.springframework.data.annotation.Transient
注釋的字段。 我也有存儲庫
public interface SettlementRepository extends JpaRepository<Settlement, Integer>
當我調用SettlementRepository.findAll();
它給出異常Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'enabled'.
如何忽略從DB加載的enabled
字段?
我找到了解決方案,問題出在Annotation @org.springframework.data.annotation.Transient
一旦我改為@javax.persistence.Transient
它運行正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.