我有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
字段?
答案 0 :(得分:7)
我找到了解决方案,问题出现在注释@org.springframework.data.annotation.Transient
中,一旦我改为@javax.persistence.Transient
它就运行良好。