-->
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 with existing table
PostPosted: Tue Sep 11, 2007 2:33 am 
Newbie

Joined: Tue Sep 11, 2007 2:24 am
Posts: 1
I'm creating a new Class for which I'm using hibernate to persist. However, it is dependent on an already existing table in the DB (which does not use hibernate). To be more concrete:

Table: DEVICE (dev_id long, name varchar ....) : This is existing table.

Table: DATA (dev_id long, key long, value text) : This is my table.

The class for my table will look like:

class Data {
private long dev_id;
private Map values;
}

For the Map, I use something like:
<hibernate-mapping>
<class name="Data" table="DATA">
<map name="mappings" table="DATA">
<key column="DEV_ID"/>
<index column="KEY" type="string"/>
<element column="VALUE" type="string"/>
</map>
...

The question is how to map the dev_id column? It will be already existing in the legacy table (DEVICE). Also hibernate should *not* update DEVICE table. It should use only for association.
Finally the relation is on-to-many. One device can have many key-value pairs.

Any help will be appreciated.
Thanks
M


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 20, 2007 12:08 pm 
Newbie

Joined: Tue Feb 06, 2007 11:59 am
Posts: 4
Quote:
<index column="KEY" type="string"/>


Should't it be <map-key> tag instead?


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.