NOo sure. Enable Hibernate degug log in 2.0.1 and lets see what it is
actually objecting to.
|---------+------------------------------------------->
| | jiesheng zhang |
| | <jasonnew2001@...> |
| | Sent by: |
| | hibernate-devel-admin@...|
| | ceforge.net |
| | |
| | |
| | 17/07/03 06:18 PM |
| | |
|---------+------------------------------------------->
>------------------------------------------------------------------------------------------------------------------------------|
| |
| To: hibernate-devel@... |
| cc: |
| Subject: [Hibernate] map works in 1.25 but not in 2.0 |
>------------------------------------------------------------------------------------------------------------------------------|
Hi, I have three classes:DeviceDB, ClientContact, and
ContactGroup.
The relationship is like this:
DeviceDB---ClientContact is 1:N
DeviceDB---ContactGroup is 1:N
ClientContact---ContactGroup is N:N
My map file is like this
<class name="DeviceDB" table="deviceDB"
discriminator-value="0">
<id name="id" column="dbID" type="long"
unsaved-value="0">
<generator class="sequence">
<param name="sequence">seq_resourceID</param>
</generator>
</id>
<discriminator column="class" length="1"/>
<subclass name="ContactDB" discriminator-value="c"
proxy="ContactDB">
<set name="items" table="contact" lazy="true"
inverse="true">
<key column="dbID"/>
<one-to-many class="ClientContact"/>
</set>
<set name="itemGroups" table="contactGroup"
inverse="true" lazy="true">
<key column="dbID"/>
<many-to-many column="groupid"
class="ContactGroup"/>
</set>
</subclass>
</class>
<class name="ContactGroup" table="contactGroup">
<id name="id" column="groupid" type="long"
unsaved-value="0">
<generator class="sequence">
<param name="sequence">seq_resourceID</param>
</generator>
</id>
<many-to-one name="database" column="dbID"
class="ContactDB" cascade="none"/>
</class>
<class name="ClientContact" table="contact">
<id name="id" column="contactID" type="long"
unsaved-value="0">
<generator class="sequence">
<param name="sequence">seq_resourceID</param>
</generator>
</id>
<many-to-one name="database" column="dbId"
class="ContactDB" cascade="none"/>
<set name="groups" table="contactAndGroup">
<key column="contactID"/>
<many-to-many column="groupID"
class="ContactGroup"/>
</set>
</class>
This map file works perfectly in hibernate 1.25.
However when I migated it from hibernate 1.25 5o 2.0
I got this error:
net.sf.hibernate.MappingException: Foreign key must
have same number of columns as referenced primary key
at
net.sf.hibernate.mapping.ForeignKey.setReferencedTable(ForeignKey.java:33)
at
net.sf.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:514)
at
net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:614)
Definitely my foreign key has same number column as
the references primary key since I use only one column
as primary key/foreign key in all my map files.
Does anyone have any idea where the error comes from?
Or any suggestion on fixing the problem.
Thanks
jason
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
hibernate-devel mailing list
hibernate-devel@...
https://lists.sourceforge.net/lists/listinfo/hibernate-devel
**********************************************************************
Any personal or sensitive information contained in this email and
attachments must be handled in accordance with the Victorian Information
Privacy Act 2000, the Health Records Act 2001 or the Privacy Act 1988
(Commonwealth), as applicable.
This email, including all attachments, is confidential. If you are not the
intended recipient, you must not disclose, distribute, copy or use the
information contained in this email or attachments. Any confidentiality or
privilege is not waived or lost because this email has been sent to you in
error. If you have received it in error, please let us know by reply
email, delete it from your system and destroy any copies.
**********************************************************************
|