I need help to create the correct pojo's from this database...
https://www.dropbox.com/s/j2lfu44zpqfcxb4/dbr.PNG
I have tried creating this classes...
@Entity @Table(name="Municipio", catalog="elecciones2014", schema="") public class Municipio implements Serializable{ @EmbeddedId private MunicipioPk idMunicipio; @Basic(optional=false) @Column(name="nomb_municipio") private String nomb_municipio; } With this Embedded class
@Embeddable class MunicipioPk implements Serializable{ /** * */ private static final long serialVersionUID = 1L; @Column(name="id_depto") String departamento; @Column(name="id_municipio") String idMunicipio; } The problem is when i want to reference to 'Municipio' from 'JRV' y don't know how to access to field 'id_municipio'. I had this code but it doesn't work
@Entity @Table(name = "JRV", catalog = "elecciones2014", schema = "") public class Jrv { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "id_jrv") private int id; @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="id_municipio",referencedColumnName="idMunicipio") private Municipio municipio; @ManyToOne @JoinColumn(name="DUI",referencedColumnName="dui") private PadronElectoral dui; } can someone help me? how I have to do it? Thanks in advice!!