-->
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.  [ 9 posts ] 
Author Message
 Post subject: Mapping Exception
PostPosted: Thu Dec 11, 2003 10:43 am 
Newbie

Joined: Wed Dec 10, 2003 11:29 am
Posts: 15
Hi,
I am getting the following mapping exception.

INFO: building session factory
net.sf.hibernate.MappingException: Repeated column in mapping for class Groupmemberinfo should be mapped with insert="false" update="false": GROUPID
at net.sf.hibernate.persister.AbstractEntityPersister.checkColumnDuplication(AbstractEntityPersister.java:970)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:844)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:41)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:136)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:720)
at Main.createDatastore(Main.java:58)
at Main.main(Main.java:39)

I have seen this exception in other forums and the explaination given by gavin was that "mapped your <many-to-one> association to the primary key column!"..........
In my case GroupID Is the PRIMARY KEY.....So then what do i do??????

Thanks always for ur prompt replies.....
Amit

These are my XML files

Groupinfo.hbm.xml file
-------------------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>

<!--
Created by Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->

<class
name="Groupinfo"
table="GROUPINFO"
>
<id
name="groupid"
type="java.lang.String"
column="GROUPID"
>
<generator class="assigned" />
</id>
<property
name="grouptype"
type="byte"
column="GROUPTYPE"
length="3"
/>
<property
name="groupname"
type="java.lang.String"
column="GROUPNAME"
length="30"
/>

<!-- associations -->
<!-- bi-directional one-to-many association to Groupmemberinfo -->
<set
name="groupmemberinfos"
lazy="true"
inverse="true"
>
<key>
<column name="GROUPID" />
</key>
<one-to-many
class="Groupmemberinfo"
/>
</set>

</class>
</hibernate-mapping>


Groupmemberinfo.hbm.xml file
------------------------------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>

<!--
Created by Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->

<class
name="Groupmemberinfo"
table="GROUPMEMBERINFO"
>
<composite-id name="comp_id" class="GroupmemberinfoPK">
<key-property name="groupid" column="GROUPID" type="java.lang.String" />
<key-property name="mdn" column="MDN" type="java.lang.String" />
</composite-id>
<property
name="presencestatus"
type="byte"
column="PRESENCESTATUS"
length="3"
/>

<!-- associations -->
<!-- bi-directional many-to-one association to Groupinfo -->
<many-to-one
name="groupinfo"
class="Groupinfo"
not-null="true"
>
<column name="GROUPID" />
</many-to-one>

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2003 11:04 am 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Use <key-many-to-one> in the <composite-id>

Something like

<key-many-to-one name="groupid" column="GROUPID" class="Groupinfo"/>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2003 11:09 am 
Newbie

Joined: Wed Dec 10, 2003 11:29 am
Posts: 15
Thanks a ton Dimas for your reply.
But It does not seem to be working ...
May be I am not putting it in the right place...

Could just let me know explicitly where to put it ...
That would be a great help...

Thanks again,
Amit


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2003 11:14 am 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
1. put

Code:
<key-many-to-one name="groupid" column="GROUPID" class="Groupinfo"/>


instead of

Code:
<key-property name="groupid" column="GROUPID" type="java.lang.String" />


in the <composite-id>

2. remove <many-to-one> from Groupmemberinfo mapping

3. update your GroupmemberinfoPK class


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2003 11:53 am 
Newbie

Joined: Wed Dec 10, 2003 11:29 am
Posts: 15
Hi Dimas,
I tried what you suggested but now I am getting the below exception.
Please direct me further. Thanks for answering my queries.

Thanks,
Amit


Dec 11, 2003 9:21:20 PM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
net.sf.hibernate.PropertyNotFoundException: Could not find a getter for groupinfo in class Groupmemberinfo
at net.sf.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:182)
at net.sf.hibernate.mapping.Property.getGetter(Property.java:179)
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:725)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:741)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:41)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:136)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:720)
at Main.createDatastore(Main.java:58)
at Main.main(Main.java:39)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2003 12:01 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
you did not perform step 2


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2003 12:18 pm 
Newbie

Joined: Wed Dec 10, 2003 11:29 am
Posts: 15
Thanks a lot Dimas...It works :))

Thanks again,
Amit


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2003 8:31 am 
Beginner
Beginner

Joined: Thu Dec 11, 2003 9:54 am
Posts: 25
dimas wrote:
1. put

Code:
<key-many-to-one name="groupid" column="GROUPID" class="Groupinfo"/>


instead of

Code:
<key-property name="groupid" column="GROUPID" type="java.lang.String" />


in the <composite-id>

2. remove <many-to-one> from Groupmemberinfo mapping

3. update your GroupmemberinfoPK class


What do you mean under point 3 ???


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2003 9:12 am 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Property of composite-id class which was String becomes Group. Nothing more.[/quote]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

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.