@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实体有关

@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从数据库加载该字段?

回答:

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

以上是 @Transient在Spring数据中不起作用 的全部内容, 来源链接: utcz.com/qa/432521.html

回到顶部