Hibernate version: 3.0.5
JBOSS Server: 4.3.0.GA
Database: Oracle10G
I am sorry to ask this question because it seems to me as some basics in SQL. Nonetheless I see nothing quite close to it in the books and web sites I am searching in.
so easy in SQL, I thought it expected it to be easy with hibernate ate well.
I have one table linked with many others. First, the DB schema is old and most of the table lacks primary keys (But embedded Id fixed that, thanks!)
Now, all I want is to make two join between table.
I basically have two table A and B. In each table, I have two common fields such as A.field1 = B.field1 and A.filed2 = B.filed2.
this a one-to-many unidirectional relation from A to B : each record from A has many related records in B.
I created an entity EA :
Code:
@Entity
@Table(name = "A)
public class EA implements Serializable {
@Id
@Column(name = "ID", nullable = false)
private Integer id;
@Column(name = "FILED1")
private String field1;
@Column(name = "FILED2")
private Integer field2;
/* + Getters and Setters */
}
and another EB :
Code:
@Entity
@Table(name = "B)
public class EB implements Serializable {
@Id
@Column(name = "ID", nullable = false)
private Integer id;
@Column(name = "FILED1")
private String field1;
@Column(name = "FILED2")
private Integer field2;
/* + Getters and Setters */
}
So how do I make my mapping so when I load an entity EA, I can have a list of all related EB? (meaning all EB respecting the joins A.field1 = B.field1 and A.filed2 = B.filed2)?