我有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'.异常(exception)

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

最佳答案

我找到了解决方案,问题出在Annotation @org.springframework.data.annotation.Transient中,一旦我更改为 @javax.persistence.Transient ,它就可以正常工作。

09-30 11:02