@Transient in spring data doesn#39;t work(春季数据中的@Transient 不起作用)
问题描述
我有结算
实体
@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
注释.我也有存储库
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();
它给出异常 Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'enabled'.
when I call SettlementRepository.findAll();
it give exception Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'enabled'.
如何忽略从数据库加载的 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.
这篇关于春季数据中的@Transient 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:春季数据中的@Transient 不起作用


- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01