我有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
,它就可以正常工作。