-->
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: basic association problem
PostPosted: Fri Nov 24, 2006 9:57 pm 
Newbie

Joined: Fri Nov 24, 2006 9:36 pm
Posts: 1
Location: Colorado, USA
I may be new to Hibernate but I've read post after post and document after document but for some reason my simple task does not work. Am I experiencing some odd dependency problem???

All I want to do is create a many-to-many relationship. Advise would be greatly appreciated. Changed names from basic event to person example with:

<hibernate-mapping>

<class name="adsea.dynosite.func.job.ServiceDO"
table="_job_service">
<id name="id"
column="_service_id"
type="java.lang.Long">
<generator class="sequence">
<param name="sequence">_job_service_id_seq</param>
</generator>
</id>
<property name="name" type="java.lang.String" column="_name" length="255"/>
<property name="price" type="java.lang.Double" column="_price"/>
<property name="loadLimit" type="java.lang.Integer" column="_load_limit"/>
<property name="minutes" type="java.lang.Integer" column="_minutes"/>
<property name="other" type="java.lang.String" column="_other" length="5000"/>
<set name="providerSet" table="_job_provider">
<key column="_service_id"/>
<many-to-many column="_provider_id" class="adsea.dynosite.func.job.ProviderDO"/>
</set>

</class>

<class name="adsea.dynosite.func.job.ProviderDO"
table="_job_provider">
<id name="id"
column="_provider_id"
type="java.lang.Long">
<generator class="sequence">
<param name="sequence">_job_provider_id_seq</param>
</generator>
</id>
<property name="name" type="java.lang.String" column="_name" length="255"/>
<property name="userId" type="java.lang.Long" column="_user_id"/>
<property name="reqdConfirmation" type="java.lang.Integer" column="_reqd_confirmation" not-null="true"/>
<property name="other" type="java.lang.String" column="_other" length="5000"/>

</class>

</hibernate-mapping>


I've built java classes to match. Get following error:

[java] INFO: Reading mappings from resource: adsea/dynosite/func/job/Job.hbm.xml
[java] Nov 24, 2006 6:54:43 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
[java] INFO: Mapping class: adsea.dynosite.func.job.ServiceDO -> _job_service
[java] Nov 24, 2006 6:54:43 PM org.hibernate.cfg.HbmBinder bindCollection
[java] INFO: Mapping collection: adsea.dynosite.func.job.ServiceDO.providerSet -> _job_provider
[java] Nov 24, 2006 6:54:43 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
[java] INFO: Mapping class: adsea.dynosite.func.job.ProviderDO -> _job_provider
[java] Nov 24, 2006 6:54:43 PM org.hibernate.cfg.Configuration doConfigure
[java] INFO: Configured SessionFactory: null
[java] Nov 24, 2006 6:54:43 PM adsea.dynosite.database.HibernateUtil <clinit>
[java] WARNING: Exception thrown: Foreign key (FK8FFDEA1230212552:_job_provider [_provider_id])) must have same number of columns as the referenced primary key (_job_provider [_service_id,_provider_id])
[java] Nov 24, 2006 6:54:43 PM adsea.dynosite.database.HibernateUtil <clinit>
[java] WARNING: org.hibernate.MappingException: Foreign key (FK8FFDEA1230212552:_job_provider [_provider_id])) must have same number of columns as the referenced primary key (_job_provider [_service_id,_provider_id])
[java] at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:90)
[java] at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:73)
[java] at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1145)
[java] at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1052)
[java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1168)
[java] at adsea.dynosite.database.HibernateUtil.<clinit>(HibernateUtil.java:23)
[java] at adsea.dynosite.common.Facade.getCurrentSession(Facade.java:50)
[java] at adsea.dynosite.common.Facade.beginTransaction(Facade.java:62)
[java] at adsea.dynosite.func.item.ItemFacade.insert(ItemFacade.java:37)
[java] at adsea.dynosite.func.item.Test.insert(Test.java:41)
[java] at adsea.dynosite.func.item.Test.main(Test.java:108)

[java] Exception in thread "main" java.lang.NoClassDefFoundError
[java] at adsea.dynosite.common.Facade.getCurrentSession(Facade.java:50)
[java] at adsea.dynosite.common.Facade.closeCurrentSession(Facade.java:110)
[java] at adsea.dynosite.func.item.ItemFacade.insert(ItemFacade.java:46)
[java] at adsea.dynosite.func.item.Test.insert(Test.java:41)
[java] at adsea.dynosite.func.item.Test.main(Test.java:108)
[java] Java Result: 1

_________________
kennyMac


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.