簡體   English   中英

彈簧數據中的@Transient不起作用

[英]@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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM