开发者

How to don't create column in hibernate include some property in entity class

开发者 https://www.devze.com 2023-04-05 02:37 出处:网络
I want to property in entity seam. But I dont want to create column in database. for example my entity is ;

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

     publ开发者_C百科ic 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 .


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.

@Transient
 public List<Product> getExample() {
       return example;
     }
0

精彩评论

暂无评论...
验证码 换一张
取 消