This week's book giveaways are in the Jython/Python and Object-Oriented programming forums. We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line! See this thread and this one for details.
I have back up table kind of thing in my database. i.e after some period some table are created newly(due to huge data present in the existing table) which is same as existing table. This new table will be used to insert new data but old table can be useful for select purpose.
So i would like to map single POJO to both table. These tables are created dynamically after particular period so at the time of generation of new table ,this table should be mapped to same POJO to which existing table was mapped...
So can i mention two tables in class tag for the mapping?
Or any other way to do this...
It is possible to map a single POJO class to two tables using Hibernate. First create your object and its related HBM (xml) file. Then copy the HBM file and rename it to something similar. In the first HBM you will have something like the following. Please note the use of entity-name element.
In the second HBM you will have something like:
Then in your data layer you will have code something like:
Of course the above requires that your table actually exist, thus the dynamic creation of the table will be a problem.
Good luck friend,
posted 9 years ago
Thank you Ran for the reply...I got it..But do i need to make two different XML for both mapping purpose.
And if I merge both XML in to one XML File then should I simply copy mapping(which is same) of both files one after another?that will create redundancy..so ideally that should not be the case..
Can you explain me How merged XML will look like?