【发布时间】:2011-08-21 21:46:32
【问题描述】:
我正在做一个应用程序在播放框架中,我需要将非实体对象的相同实例存储到 JPA 实体中而不将其持久化到数据库中,我想知道是否有可能实现这一点注释。我正在寻找的示例代码是:
public class anEntity extends Model {
@ManyToOne
public User user;
@ManyToOne
public Question question;
//Encrypted candidate name for the answer
@Column(columnDefinition = "text")
public BigInteger candidateName;
//I want that field not to be inserted into the database
TestObject p= new TestObject();
我尝试了@Embedded 注释,但它应该将对象字段嵌入到实体表中。无论如何在实体表中隐藏对象列的同时使用@Embedded?
【问题讨论】:
-
我编辑了问题并回答了一点,以澄清应始终使用相同的瞬态实例。希望你不介意..
标签: java hibernate jpa singleton transient