@Spring在春季数据不起作用 [英] @Transient in spring data doesn't work

查看:122
本文介绍了@Spring在春季数据不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有结算实体

@Entity
@Table(name = "settlement")
public class Settlement {

    @ManyToOne
    @JoinColumn(name = "subscription_x_product_id")
    private ProductSubscription productSubscription;

ProductSubscription entity

@Entity
@Table(name = "subscriptionproduct")
public class ProductSubscription {
    @ManyToOne
    @JoinColumn(name = "product_id")
    private Product product;

产品实体

@Entity
public class Product {
    @Transient
    private String enabled;

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

in Product entity i have field enabled which annotated with @org.springframework.data.annotation.Transient. also I have Repository

public interface SettlementRepository extends JpaRepository<Settlement, Integer>

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

如何忽略从数据库加载的启用的字段?

How can I ignore the enabled field from being loaded from the DB ?

推荐答案

我找到了解决方案,问题出现在Annotation @ org.springframework.data.annotation.Transient 中,一旦我改为 @ javax.persistence.Transient 它工作得很好。

I found the solution, the problem was in Annotation @org.springframework.data.annotation.Transient once I changed to @javax.persistence.Transient it worked fine.

这篇关于@Spring在春季数据不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆