简体   繁体   English

弹簧数据中的@Transient不起作用

[英]@Transient in spring data doesn't work

I have Settlement entity 我有Settlement实体

@Entity
@Table(name = "settlement")
public class Settlement {

    @ManyToOne
    @JoinColumn(name = "subscription_x_product_id")
    private ProductSubscription productSubscription;

which related to ProductSubscription entity ProductSubscription实体相关

@Entity
@Table(name = "subscriptionproduct")
public class ProductSubscription {
    @ManyToOne
    @JoinColumn(name = "product_id")
    private Product product;

which related to Product entity Product实体相关

@Entity
public class Product {
    @Transient
    private String enabled;

in Product entity i have field enabled which annotated with @org.springframework.data.annotation.Transient . Product实体中,我已enabled使用@org.springframework.data.annotation.Transient注释的字段。 also I have Repository 我也有存储库

public interface SettlementRepository extends JpaRepository<Settlement, Integer>

when I call SettlementRepository.findAll(); 当我调用SettlementRepository.findAll(); it give exception Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'enabled'. 它给出异常Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'enabled'.

How can I ignore the enabled field from being loaded from the DB ? 如何忽略从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