如何不在休眠中创建列,包括实体类中的某些属性
我想要实体接缝中的属性。但我不想在数据库中创建列。例如我的实体是;
@Entity
public class Category extends Item implements Serializable {
private static final long serialVersionUID = -1154500438874768209L;
private List<Product> example;
private List<Item> children;
public void addChild(Item child) {
if (children == null) {
children = new ArrayList<Item>();
}
if (!children.contains(child)) {
children.add(child);
}
}
@OneToMany(cascade = CascadeType.ALL)
public List<Item> getChildren() {
return children;
}
public void setChildren(List<Item> children) {
this.children = children;
}
public void setExample(List<Product> example) {
this.example = example;
}
public List<Product> getExample() {
return example;
}
}
在此实体子列表中是映射数据库,但我不想在数据库中映射示例列表。我该怎么办?
谢谢 。
I want to property in entity seam. But I dont want to create column in database. for example my entity is ;
@Entity
public class Category extends Item implements Serializable {
private static final long serialVersionUID = -1154500438874768209L;
private List<Product> example;
private List<Item> children;
public void addChild(Item child) {
if (children == null) {
children = new ArrayList<Item>();
}
if (!children.contains(child)) {
children.add(child);
}
}
@OneToMany(cascade = CascadeType.ALL)
public List<Item> getChildren() {
return children;
}
public void setChildren(List<Item> children) {
this.children = children;
}
public void setExample(List<Product> example) {
this.example = example;
}
public List<Product> getExample() {
return example;
}
}
in this entity children list is mapping database but I dont want to map example list in database. Hown can i do?
thx .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不想在 Seam (Hibernate) 中保留类的属性,请在属性本身或使用 @Transient 注释的 getter 上注释该属性。 IE
If you don't want to persist a property of a class in Seam (Hibernate), annotate that property, either on the property itself or on the getter with the @Transient annotation. i.e.