It's not a secret anymore!*
The moose likes Object Relational Mapping and the fly likes How to achieve transparency layers using ORM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to achieve transparency layers using ORM" Watch "How to achieve transparency layers using ORM" New topic
Author

How to achieve transparency layers using ORM

ajay mittal
Greenhorn

Joined: Nov 23, 2011
Posts: 24
Hi All,

Currently i am using ORM through hibernate in a project where i have two options while designing my data models and its mapping with db tables.

1. Create the data models a replica copy of tables in db, so that while using hibernate i can easily map each row to a object in java. but leads me to a large size of data in db. Which can be a performance hindrance parameter
after 1-2 years.

2. I can create data models by using my own explicit logic on objects obtained from db, in this case also i will use hibernate but i have to create my own new data models for internal functioning of application after using data from data models mapped to certain tables in db. This will even reduce size of my tables to a great extent and will not cause any performance hindrance but this will break the ORM pattern partially because it will give be objects but i have to convert them into one useful for my application logic.

Please suggest me the write approach to be used.

Regards,
Ajay
Emanuel Kadziela
Ranch Hand

Joined: Mar 24, 2005
Posts: 186
I don't understand why having a data model in your code be a replica of tables in db increases the size of the database. If the database architecture is done correctly, the database is not de-normalized in some erroneous way, than the amount of data should not be affected by how you map it through ORM. Perhaps the database architecture needs to be re-evaluated. Can you give an example of why you think you will have a larger size of data and negative performance impact if you choose option 1?

Option 2 sounds like you are asking for trouble. Perhaps it's the way you described it, but it seems to me you are proposing to introduce another data translation layer in your code.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to achieve transparency layers using ORM
 
Similar Threads
Framework for application with catalog&data tables - Gui component
is hibernate solved these problem?
When to use ORM?
Java discourages intelligent use of database technology: Discuss.
Advantages of Hibernate