Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping POJO to Entities

In our project we have a constraint of not having the luxury to alter the table structure already in place. The tables are highly denormalized in nature.

We have come up with good POJOs for the application. We have the Entity beans generated out of the exiting tables. Now we have to map the POJOs to the entities so that we can persist.

Ultimately, we combine a good POJO with a bad table. Any thoughts on options/alternatives/suggestions to this approach?

like image 341
Sripaul Avatar asked Nov 15 '22 00:11

Sripaul


1 Answers

Hibernate/JPA(2) has a rich set of functionality to manipulate the mapping (so that your objects can differ from the tables), so that many (NOT ALL) old tables can be mapped to normal object. -- May you should have a look at this first, any use your pojo/table-"solution" only if this mapping is not powerful enough.


If you have a read only application, you can think of using views to make your table/views more like you objects. This may reduse the amount of strange mapping.


I don't know your mapping, size of the application or use case, but have you considered not to use Hibernate? I ask this, because I can imagine (how I said: I don't know you application), that in a architecture like this, no Hibernate feature is used and so Hibernate will add only a not needed complexity.

like image 193
Ralph Avatar answered Dec 04 '22 15:12

Ralph