-->
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.  [ 1 post ] 
Author Message
 Post subject: Using Hibernate on a table without a primary key
PostPosted: Mon Jan 04, 2010 9:13 am 
Newbie

Joined: Fri Jan 01, 2010 12:17 pm
Posts: 4
I am (hopefully) just about to start on my first Hibernate project and have come across a stumbling block. Would appreciate any advice.

I am working on a project where my new code will run side-by-side with legacy code and I cannot change the data model at all. I have come across a situation where one of the main tables has no primary key. It is something like this:

Say there is an order table and a product table, and a line_item table which lists the products in each order (i.e. consits of order_id, product_id, and quantity). In this data model it is quite possible to have 2 line items for the same product in the same order. What happens in the existing code is that whenever the user updates a line item, all line items for that order are deleted and re-inserted. Since even a compound key of all the fields in the line_item table would not necessarily be unique, that is the only possible way to update a line item in this data model.

I am prepared to guarantee that I will never attempt to update or delete an indivdual line item. Can I make my Hibernate code work in the same way as the existing code? If not, does this mean I (a) I cannot use Hibernate at all; (b) I cannot use Hibernate to map the line_item table; or (b) I can still map this table but not its relationships

Thanks in advance for any advice

(btw I am actually using NHibernate but the java forums are better attended than the .Net ones and I presume the basic strategy will be the same)

--- Tim


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

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.