Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » How to save data in different tables with one entity(How to save data in different tables with one entity)
How to save data in different tables with one entity [message #650537] Tue, 25 January 2011 13:07 Go to next message
imran raza khan is currently offline imran raza khanFriend
Messages: 18
Registered: January 2011
Junior Member
Hi,

I have multiple tables with same columns like

id,mobilenumber,message

Now on the base of different body of message i have to save data in different tables.

Now if i create entity for each table then only change is table name.

is there any possibility that i save data with one entity? or i have to create entities?

Regards,
imran
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 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

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 Go to previous message
imran raza khan is currently offline imran raza khanFriend
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

Previous Topic:Help, default entity listeners not being invoked
Next Topic:struggling to call a stored procedure with OBJECT parameter...
Goto Forum:
  


Current Time: Fri Apr 26 21:59:12 GMT 2024

Powered by FUDForum. Page generated in 0.03299 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top