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
|