小编典典

@Transient在Spring数据中不起作用

hibernate

我有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'.

如何忽略enabled从数据库加载该字段?


阅读 1120

收藏
2020-06-20

共1个答案

小编典典

我找到了解决方案,问题出在“注释”中,@org.springframework.data.annotation.Transient当我将@javax.persistence.Transient其更改为正常时。

2020-06-20