I'm trying to set up the mapping files.  I've got several many to many mappings.  One in particular includes needs of families.  Needs include having an elderly person in the home, not having transportation, or having small children for instance.  I have a table to store family information(family_t) and a table to store needs of families(potential_need_t).  So, I created an intermittant table(family_need_t) connecting the two so I can have two many-to-one relationships.  That's what the hibernate book said to do.  In doing that I used a composite id in the family_need_t, because the combination of primary keys from the other tables must be unique.
 
Anyhow, I have two problems.  First, when I try to generate the ddl, I get the following error:
 

testGenerateDdl(

org.lds.wilmington.christiana.preparedness.PersistenceTest)org.hibernate.MappingException: Association references unmapped class: org.lds.wilmington.christiana.preparedness.data.FamilyNeed
 
Second, in trying to research the problem I came across a forum where someone said it is a bad idea to use composite id's because it is a huge performance hit.  I've also read that it's a bad idea to use many-to-many relationships, so I'm wondering what the preferred thing to do is when one has a many to many relationship.
 
I've included the mapping files below.  Are these questions you would know the answer too?  I would be happy to send you the code if you would be willing to look at it.  If not, that's ok, I was about to post a message in a hibernate forum, and see if anyone there could help me.  Thanks a ton.
 
 
 

<?xml

version="1.0"?>

<!DOCTYPE

hibernate-mapping PUBLIC

"-//Hibernate/Hibernate Mapping DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping

package="org.lds.wilmington.christiana.preparedness.data" >

<class name="PotentialNeed" table="potential_needs_t">

<id name="potentialNeedId" column="potential_need_id" type="int" >

<generator class="sequence" />

</id>

<property name="potentialNeed" column="potential_need" type="string" />

<set name="familyNeeds" inverse="true" table="family_need_t" >

<key column="potential_need_id" />

<one-to-many class="FamilyNeed" />

</set>

</class>

</hibernate-mapping>

 

<?xml

version="1.0"?>

<!DOCTYPE

hibernate-mapping PUBLIC

 

"-//Hibernate/Hibernate Mapping DTD 3.0//EN"

 

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping

package="org.lds.wilmington.christiana.preparedness.data" >

 

<class name="FamilyNeed" table="family_need_t">

 

<composite-id>

 

<key-many-to-one name="familyId" class="Family" column="family_id" />

<key-many-to-one name="potentialNeedId" class="PotentialNeed" column="potential_need_id" />

</composite-id>

</class>

</hibernate-mapping>

 

<?xml

version="1.0"?>

<!DOCTYPE

hibernate-mapping PUBLIC

"-//Hibernate/Hibernate Mapping DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping

package="org.lds.wilmington.christiana.preparedness.data" >

<class name="Family" table="family_t">

<id name="familyId" column="family_id" type="int" >

<generator class="identity" />

</id>

<property name="streetAddress" column="street_address" type="string" />

<property name="zipCode" column="zip_code" type="int" />

<property name="gridNumber" column="grid_number" type="string" />

<property name="emergencyName" column="emergency_name" type="string" />

<property name="ableToHousePeople" column="able_to_house_people" type="boolean" />

<property name="numAdultsCanHouse" column="num_adults_can_house" type="int" />

<property name="numChildrenCanHouse" column="num_children_can_house" type="int" />

<property name="notes" column="notes" type="string" />

<property name="dateAltered" column="date_altered" type="date" />

<set name="familyMembers" table="person_t">

<key column="person_id"/>

<one-to-many class="Person" />

</set>

<many-to-one name="city" column="city_id" class="City" />

<many-to-one name="neighborhood" column="neighborhood_id" class="Neighborhood" not-null="false"/>

<set name="familyNeeds" inverse="true" table="family_need_t" >

<key column="potential_need_id" />

<one-to-many class="FamilyNeed" />

</set>

<set name="familyResources" inverse="true" table="family_resources_t" >

<key column="resource_id"/>

<one-to-many class="FamilyResource" />

</set>

<set name="familySkills" inverse="true" table="family_skill_t" >

<key column="skill_id"/>

<one-to-many class="FamilySkill" />

</set>

</class>

</hibernate-mapping>


 
On 1/10/06, Manfred Riem <[EMAIL PROTECTED]> wrote:
Hi Jay,
 
I have been using Hibernate .... what's your problem ;)

Kind regards,
----
Manfred Riem

 


From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Jay Askren
Sent: Tuesday, January 10, 2006 8:38 PM
To: LDS Open Source Software
Subject: [Ldsoss] Emergency Preparedness Software

 
I sent an email the other day about software I'm creating for my ward.  I created a little web page so you can get an idea of what it will do and look like:
 
 
Also, if there are any Java developers out there who have used Hibernate, I would be interested in talking to you.  I've been having a little trouble using it.
 
Jay
 
 

_______________________________________________
Ldsoss mailing list
[email protected]
http://lists.ldsoss.org/mailman/listinfo/ldsoss



_______________________________________________
Ldsoss mailing list
[email protected]
http://lists.ldsoss.org/mailman/listinfo/ldsoss

Reply via email to