【发布时间】:2017-12-13 21:19:35
【问题描述】:
我有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 字段?
【问题讨论】:
-
enabled的setter上你有注解吗? -
@Jens 不,我在 setter 或 getter 上没有任何注释。
标签: java spring hibernate jpa spring-data