-->
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: How to use POJO without mapping to a table?
PostPosted: Tue Oct 26, 2004 6:46 am 
Newbie

Joined: Wed Aug 25, 2004 3:56 am
Posts: 2
Hibernate version:
2.1

I ran into a problem while creating mapping for legacy data, which is not designed quite clearly.

I have the following mappings:

[code]
<class name="Office" table="OFFICE">
<composite-id>
<key-property name="code" column="CODE" ... />
<key-property name="validToDate" column="VALID_TO_DATE" ... />
</composite-id>
...
</class>

<class name="Characteristics" table="CHARACTERISTICS">
...
<many-to-one ... class="Office">
<column name="CODE" />
</many-to-one>
</class>
[/code]

The table OFFICE contains historical data (hence the VALID_TO_DATE column) but CHARACTERISTICS refers to OFFICE regardless of date. I can't map the CHARACTERISTICS.CODE column to the OFFICE.CODE column because the OFFICE.CODE column is only part of the key.

The only working solution I know would be to add new trivial table, say, HISTORYLESS_OFFICE with one id column CODE and create many-to-one mappings Characteristics -> HistorylessOffice and Office -> HistorylessOffice. I successfully applied this solution a month ago, but I cannot change the database model at present. It would help me if I could only define the HistorylessOffice class but the class would not have any equivalent table.

Please, is there any possibility of doing it? Or some quite another way to work around it?
Thanks for any help.
Tomas


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.