|Re: How to save data in different tables with one entity [message #651037 is a reply to message #650537]
||Thu, 27 January 2011 09:32
| James Sutherland
Registered: July 2009
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
|Re: How to save data in different tables with one entity [message #651164 is a reply to message #651037]
||Fri, 28 January 2011 01:08
| imran raza khan
Registered: January 2011
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.
Powered by FUDForum
. Page generated in 0.01499 seconds