-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Mapping all domain objects to one table
PostPosted: Tue Feb 10, 2004 5:21 am 
Newbie

Joined: Tue Feb 10, 2004 5:04 am
Posts: 3
Hallo.

I'm currently working with an legacy application which is a little specific. It is all "Object Orientet" but it uses ONE data base table to store ALL domain objects poperties. This table has the following structrure:

PROPERTIES(
OBJECT_ID,
PROPERTY_NAME,
PROPERTY_VALUE
)

There is also table

OBJECTS (
OBJECT_ID,
CLASS
)

which holds information about objects and their classes.

My question is:

Is it possible to map such schema to POJO using Hibernate?
Can Hibernate help in this case?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 10, 2004 5:25 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Not really, as this is not a good relational model, but a simple EAV (entity attribute value) approach. You don't need a database for this, it's the same as "record" files in the 1960s.

There is no data integrity, no structure to query and certainly not safe data. If you have one misbehaving application accessing this database, it's all over.

EAV is the right approach for very rare cases, as an addition to a normalized relational model of entities, i.e. if full dynamic attributes are required without changes to the database schema.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: All domain objects in one table
PostPosted: Tue Feb 10, 2004 5:58 am 
Newbie

Joined: Tue Feb 10, 2004 5:04 am
Posts: 3
Thanks for quick answer!!!

I agree that its not good relational data model, but it works currently.

If i want to change it i must have good reasons, so this is my next question:

What if object properties changes due to requirements?

Does Hibernate support automatic altering of tables/databse?

Can I add new objects without "handy written" SQL?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 10, 2004 6:13 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This "model" only works if your data is not important, i.e. if you don't care about data integrity. This is not a database, but a simple file storage.

Hibernate can automatically generate a schema and even update it (although this is limited, depending on your database and JDBC driver quality). You don't have to write SQL with Hibernate, but this is not important: You have to at least know what a relational database is and how SQL works if you want to successfully use Hibernate. Start here first...

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 10, 2004 6:44 am 
Newbie

Joined: Tue Feb 10, 2004 5:04 am
Posts: 3
Well...

I'm new in "Java World", but i know SQL and few other languages quite well i think...

Well, lest's summarize: I am the rare case!

Thaks for help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.