zoukankan      html  css  js  c++  java
  • 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;
    }

    }

  • 相关阅读:
    DS02--线性表
    DS01--抽象数据类型
    C语言最后一次作业--总结报告
    C语言第十一次作业--函数嵌套调用
    你还有很多要学的东西
    Google Guice 系列教程 - 基础实践
    Eclim指令集
    maven入门案例
    从java调用groovy
    linux下安装Groovy环境
  • 原文地址:https://www.cnblogs.com/zhangmingcheng/p/5382105.html
Copyright © 2011-2022 走看看