我有Settlement实体
Settlement
@Entity @Table(name = "settlement") public class Settlement { @ManyToOne @JoinColumn(name = "subscription_x_product_id") private ProductSubscription productSubscription;
与ProductSubscription实体有关
ProductSubscription
@Entity @Table(name = "subscriptionproduct") public class ProductSubscription { @ManyToOne @JoinColumn(name = "product_id") private Product product;
与Product实体有关
Product
@Entity public class Product { @Transient private String enabled;
在Product实体中,我enabled有用注释的字段@org.springframework.data.annotation.Transient。我也有仓库
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'.
SettlementRepository.findAll();
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'enabled'.
如何忽略enabled从数据库加载该字段?
我找到了解决方案,问题出在“注释”中,@org.springframework.data.annotation.Transient当我将@javax.persistence.Transient其更改为正常时。
@javax.persistence.Transient