@Transient在Spring数据中不起作用
我有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
实体有关
@Entitypublic 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
从数据库加载该字段?
回答:
我找到了解决方案,问题出在“注释”中,@org.springframework.data.annotation.Transient
当我将@javax.persistence.Transient
其更改为正常时。
以上是 @Transient在Spring数据中不起作用 的全部内容, 来源链接: utcz.com/qa/432521.html