single pojo two diffrent tables
HI, can any one suggest me the scenario where i need to pick the table based on a flg dynamically
thanks
Can you be somewhat more precise in your questions?
Answer differs depending on tools that you use (JDBC, Hibernate, iBatis, ...).
Originally Posted by praveens18HI, can any one suggest me the scenario where i need to pick the table based on a flg dynamically
thanks
my requirement is to build in hibernate
Originally Posted by praveens18my requirement is to build in hibernate
And why you need 2 different tables? May you elaborate some more on the basis for this requirement.
Do I understand correctly that you want to save some objects of the class YourClass to table A and other objects of the same class YourClass (not its subclasses!) to the table B depending on content of that object (mpre precisely, depending on the state of the some quot;flagquot; field).
To my best knowledge the answer is quot;noquot;, you can not. The single class can be mapped to one table only.
Regards,
Oleksandr
Ya your understand is correct i want to save object myclass to table A or Table B based on a flag
Originally Posted by praveens18Ya your understand is correct i want to save object myclass to table A or Table B based on a flag
But what for? And must object migrate from one table to other in case of flag value change?
our design is like that from online need to go table A for bach need to go table b both of these same business condetions will uplay thats why i am searchi for runtime table change
Originally Posted by praveens18our design is like that from online need to go table A for bach need to go table b both of these same business condetions will uplay thats why i am searchi for runtime table change
Then why your design in such a way? What is reasoning behing this design?
Just off top of the head it sounds somewhat strange.
Regards,
Oleksandr
Originally Posted by praveens18our design is like that from online need to go table A for batch need to go table b both of these same business condetions will uplay thats why i am searchi for runtime table change
Well in JDO an option is to have one PMF for one configuration (day), and one PMF for another (batch) and the app persists via the PMF that applies at that time.
Yes, when it depends on time of the day that another matter - with hibernate you re-instantiate the SessionFactory with different set of mappings. But original requirement was save object based on the flag inside object. It means that in the same point in time one object shall be targeted to table A and other object of the same class to table B.
As I have said such design looks flawed till not proved otherwise.Originally Posted by andyWell in JDO an option is to have one PMF for one configuration (day), and one PMF for another (batch) and the app persists via the PMF that applies at that time. |