加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – Spring数据中的@Transient不起作用

发布时间:2020-12-15 04:39:28 所属栏目:Java 来源:网络整理
导读:我有结算实体 @Entity@Table(name = "settlement")public class Settlement { @ManyToOne @JoinColumn(name = "subscription_x_product_id") private ProductSubscription productSubscription; 与ProductSubscription实体相关 @Entity@Table(name = "subscr
我有结算实体

@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;

在产品实体中,我已启用了使用@ org.springframework.data.annotation.Transient注释的字段.
我也有存储库

public interface SettlementRepository extends JpaRepository<Settlement,Integer>

当我调用SettlementRepository.findAll();它给出异常引起:com.microsoft.sqlserver.jdbc.SQLServerException:无效的列名’enabled’.

如何忽略从DB加载的启用字段?

解决方法

我找到了解决方案,问题出现在Annotation @ org.springframework.data.annotation.Transient中,一旦我改为 @javax.persistence.Transient就行了.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读