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
|