Wednesday, October 6, 2010

Hibernate two tables and one object

Programmer Question

Hello,



I have this situtation:



Table1: 
tab_id
field11
field12


Table2
id
tab_id
field21
field22


I have to create one object on this two tables for example:



object: 

@Id
tabId

@Colummn(name="field11")
field11

@Colummn(name="field12")
field12

@Colummn(name="field21")
field21


When i update field21 table2 should update this field, but table1 doesn't have any information about table2, only table2 hat foreign key to table1



Any idea how i should this make ?



I cannot change table structure, i can only create new class in java.



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails