|
Re: How to save data in different tables with one entity [message #651037 is a reply to message #650537] |
Thu, 27 January 2011 14:32 |
|
You want a single Entity to be inserted into multiple duplicate tables?
You could you a multiple table descriptor and map the other table as @SecondaryTable, but this will join the table on reads, and require you have duplicate attributes or use a transformation mapping.
How do you want the Entity read, from which table?
You could use a @MappedSuperclas or TABLE_PER_CLASS inheritance and have a different subclass map each table. If you want the persist of one Entity to auto persist the others, you could do this in a prePersist event.
You could also maintain the other tables using a database trigger, this may make the most sense.
James : Wiki : Book : Blog : Twitter
|
|
|
Re: How to save data in different tables with one entity [message #651164 is a reply to message #651037] |
Fri, 28 January 2011 06:08 |
imran raza khan Messages: 18 Registered: January 2011 |
Junior Member |
|
|
Hi James,
Thanks for your reply, couple of more points to mention
1- My application is only inserting data in different tables.
2- Database trigger will not help me please see below example
I receive SMS from subscribers and my records will be like that
id, shorcode, mobilenumber, message
1, 321, 123456, b
2, 321, 123456, fm
3, 321, 123456, del
4, 321, 123456, add
Now what my application will do is that it check
if message equal to b
insert into billinfo table
if message equal to fm
insert into freemin table
if message equal to del
insert into deletion table
I hope now my requirements are more clear.
Regards,
imran
|
|
|
Powered by
FUDForum. Page generated in 0.03299 seconds