-->
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: Newby Mapping Question
PostPosted: Fri Jun 08, 2007 2:04 pm 
Newbie

Joined: Fri Jun 08, 2007 1:52 pm
Posts: 1
I have only been using hibernate for a couple days now, so excuse me if this is very basic.

I have the following tables defined and I am trying to map them using hibernate:
entities- entityID, guid, createDate
emailAddresses- emailAddressID, emailAddressTypeID, entityID, emailAddress
emailAddressTypes- emailAddressTypeID, emailAddressType

I also have an Entity, EmailAddress, and EmailAddressType class and I am trying to map the three together.
My Entity class looks something like this:

public class Entity{
private Map<EmailAddressType, EmailAddress> emailAddresses = new HashMap<EmailAddressType, EmailAddress>();
}

What I would like to do is create a HashMap or Map with the EmailAddressType object as the key and the EmailAddress object as the value. This is what I have so far, but I am not sure if this is the right way to do this or not. Any help or direction would be appreciated.


Hibernate version: 3.2.4

Mapping documents:
<hibernate-mapping package="com.tanjible.core">
<class name="Entity" table="entities" schema="core" catalog="core">
<id name="entityID" type="int">
<generator class="increment" />
</id>
<map name="emailAddresses" table="emailAddresses" inverse="true">
<key column="entityID" />
<map-key formula="(select emailAddressType from EmailAddress where EmailAddress.emailAddressTypeID = EmailAddressType.emailAddressTypeID" type="string" />
<one-to-many class="EmailAddress" />
</map>
</class>
</hibernate-mapping>

Name and version of the database you are using: MSSQL 2005


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.