• hibernate一对多注解


    package net.zmcheng.model;

    import java.util.HashSet;
    import java.util.Set;

    import javax.persistence.CascadeType;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.FetchType;
    import javax.persistence.GeneratedValue;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.OneToMany;
    import javax.persistence.Table;


    @Entity
    @Table(name="Province")
    @SuppressWarnings("serial")
    public class Province implements java.io.Serializable{
    private Integer id;
    private String name;
    private Set<City> citys = new HashSet<City>();
    @OneToMany(targetEntity=City.class,cascade={CascadeType.ALL},fetch = FetchType.EAGER)
    @JoinColumn(name="pro_id",updatable=false)
    public Set<City> getCitys() {
    return citys;
    }

    public void setCitys(Set<City> citys) {
    this.citys = citys;
    }


    @Id
    @GeneratedValue
    public Integer getId() {
    return id;
    }

    public void setId(Integer id) {
    this.id = id;
    }
    @Column(name="name")
    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }

    }

  • 相关阅读:
    MFC总结
    工作项目总结
    关于多线程使用sqlite3的问题
    vs调试时,不显示局部变量
    oracle和mysql互相迁移
    oracle如何设置ip访问数据库
    win7 安装oracle 11g图文步骤
    Mybatis传参
    别纠结mybatis啦,赶紧来瞅瞅吧
    程序员和管理常用的网站地址
  • 原文地址:https://www.cnblogs.com/zhangmingcheng/p/5382105.html
Copyright © 2020-2023  润新知