-->
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.  [ 3 posts ] 
Author Message
 Post subject: using hibernate with oddly normalized databases
PostPosted: Fri Aug 29, 2003 1:00 pm 
Regular
Regular

Joined: Fri Aug 29, 2003 12:48 pm
Posts: 63
Hi folks. I'm using hibernate for a couple of projects just peachily, except for some problems mapping valued ternary associations. I'm interested, however, in the possibility of using hibernate on, how shall we say, some oddly normalized "legacy" databases.

For example, in this database, parent-child relationships aren't indicated by the child object storing a foreign key reference to its parent object. Rather, the parent object has a column which contains a comma-separated list of child object keys. Usually it's commas, anyway. Sometimes it's spaces. Sometimes it's both.

Another fun way they denote relationships - when there is a fixed number of parents, often the child tables will have a binary column for each parent, indicating if the child belongs to that parent or not.

Would it be terribly difficult to modify hibernate to support these weird types of schema? Would it be something you'd want to do with interceptors, or would you want to mess with hibernate itself? Just curious. I can't imagine many people would want this sort of feature, but I also can't imagine that I'm the only one who could use it either.

Thanks for any tips.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 29, 2003 2:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Urrrgghhh. Pain.


You can handle these kinds of situations with a UserType; of course, you lose some of Hibernate's association-specific semantics. But it should _work_.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 29, 2003 5:25 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I recommend you restructure your database. Really, migrating this structure to a proper constrainted schema will not only safe you time with Hibernate, but everyone working with this system in the future will be very very grateful. I don't even mention that your data is not "safe" in any way right now and can only hope that it is not important to your business.

For the specific problem in our post, a new and properly constrained temporary table and a SELECT INTO would be all.

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.