Hi,
i`m currently trying to map a legacy DB in hibernate. Everything went pretty smooth until now. I encountered a situation to which I can`t find a proper solution.
The situation :
-----------------
| Table A |
-----------------
| id | SomeInfo |
-----------------
--------------------
| Table B |
--------------------
| i | d | SomeInfo |
--------------------
Example :
id = 1020 --> relation to B
i = 10
d = 20
i+d = 1020 --> relation to A
I`ve tried to create a custom key and use the key in both maps.
MyKey example :
public class MyKey implements Serializable
{
private String i;
private String d;
public MyKey(String i, String d)
{
this.i = i;
this.d = d;
}
public ProductCode(String id)
{
this.i = id.subString(0, 1);
this.i = id.subString(1, 2);
}
public ProductCode()
{
}
}
MyKey doesn`t map with mapgenerator because it`s missing a unique ID (which I understand).
What is the right way to solve this ? And could someone give an example of how the hibernate mappings for Table A and Table B should look like?
|