-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mapping problem - two tables, one entity
PostPosted: Mon Sep 29, 2008 12:05 pm 
Newbie

Joined: Wed May 28, 2008 12:06 pm
Posts: 3
Hello all, I’m hoping for some assistance in figuring out how to implement a fairly complex mapping problem. Here is what I have to deal with in a legacy database situation (that I can't change - I have to adapt the mapping to):

    1. Our current purchase order information is stored on a table called ‘PURCHASE_ORDER’.
    2. Our older purchase order information is stored in an identical (structure-wise) table called ‘PURCHASE_ORDER_HIST’.
    3. The primary key to these tables is PO_NUMBER and PO_SEQUENCE.
    4. A given PO_NUMBER and PO_SEQUENCE will exist on either PURCHASE_ORDER or PURCHASE_ORDER_HIST, but not both.
    5. The legacy applications that need to retrieve information for a given PO_NUMBER and PO_SEQUENCE have to query both tables to locate the information.


I have an entity class called PurchaseOrder which I need to somehow map to BOTH tables and have the persistence layer automagically load the data. So far, I have only mapped this entity to the PURCHASE_ORDER table, and now need to figure out some way to also map it to PURCHASE_ORDER_HIST.

Basically, the persistence manager needs to query PURCHASE_ORDER, and if it doesn't find it there, query PURCHASE_ORDER_HIST. I'm currently just figuring out how to get it to load the correct entity; eventually, I'm going to have to try to figure out how get the persistence layer to update the correct table if an entity is changed.

Is this a scenario where some sort of Inheritance mapping could help?

Thanks for any help.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 02, 2008 4:12 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

maybe you can utilize the Custom SQL for CRUD operations feature - http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/#entity-hibspec-customsql.

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.