Hibernate persist object graph spread in two database -


if 1 object need save in database property needs save in different database should approach?

example

calss address {     string owner_name,     string house_no, }  class employee {     list<address> addlst; } 

in situation have address table in db1 , employee table in db2 , need save employee object @ 1 go.

i know hibernate not suitable in situation there way can results below?

db1:

employee ---------- emp_id  addredd_id 1       1 

db2:

address ---------- address_id   owner   house_no 1            abc     bd/12 

there no constraints database side.

you can use postflush listener - when employee object flushed database can hold of address list , save using different session.

you need same loading well.

this approach lead lot of problems later on.

it better have wrapper function saves these 2 things separately , use every else.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -