Hi,
am using hibernate 3.5.4
I have defined a Class like this:
ClassA.java
------------------------
Code:
@Entity
@Table(name="TABLE1")
Class ClassA{
.
.
.
@Column(name="REF_B")
private String a_obj;
@OneToMany(fetch=FetchType.EAGER)
@JoinTable(joinColumns = {
@JoinColumn(name = "REF_A", referencedColumnName = "REF_B", unique = false, nullable = true)
})
private List<BClass> a_Objects;
..
//getters and setters
}
AND
ClassB.java
-------------------------
Code:
@Entity
@Table(name="TABLE2")
Class ClassB{
.
.
.
@Column(name="REF_A")
private String b_object;
..
//getters and setters
}
---------------------------
The Basic Idea is this...
1. I have a Table '
TABLE1'; which has a column '
TABLE1.
REF_B' (Non-Unique/Nullable).
2. This column may contain a String value.
3. This String value will be present in some or the other row in '
TABLE2' matching with '
TABLE2.
REF_A ' column (Non-unique/nullable).
4. It is possible and valid that there might be many rows in
TABLE2 havings same value for
REF_A.
5. All the rows from
TABLE2 which match
TABLE1.
REF_B value must be populated in the
'List<BClass> a_objects'.
The mapping which i have defined above is not working, it gives me an error like..
Invalid object name 'TABLE1_TABLE2'
Is there something i am missing in the mapping? It is supposed to be Unidirectional and without a join table.
Note:
REF_A and
REF_B are not primary or foreign keys.