-->
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.  [ 6 posts ] 
Author Message
 Post subject: row is not inserting into child
PostPosted: Sat Apr 23, 2005 2:53 pm 
Newbie

Joined: Sat Apr 02, 2005 10:32 am
Posts: 14
Hi,
I am working with ssimple parent /child relationship and i am getting the following exception

org.hibernate.MappingException: Repeated column in mapping for entity:
OrderPermitUnitDetail column: OrderNumber (should be
mapped with insert="false" update="false")

I am using the following code.


Mapping file for Parent Class: OrderPermit
<set
name="orderPermitUnitDetails"
lazy="false"
inverse="false"
cascade="all"
>
<key>
<column name="orderNumber" />
</key>
<one-to-many
/>
</set>


Mapping file for Child class :



<class
name="OrderPermitUnitDetail" table="orderpermitunitdetail">
<composite-id name="comp_id" class="OrderPermitUnitDetailPK">
<key-property
name="orderNumber"
column="OrderNumber"
type="java.lang.Integer"
length="11"
/>
<key-property
name="tbilotNumber"
column="TBILotNumber"
type="java.lang.String"
length="20"
/>
</composite-id>
<many-to-one
name="orderPermitDTO"
class="OrderPermitDTO"
not-null="true"
column="OrderNumber"
cascade="none"
outer-join="auto"
/>



and in Client program I am calling like this:


orderPermitDTO.setFoundationsystem("PA");
orderPermitDTO.setFoundationwallheight("PA");
orderPermitDTO.setAttachedBuildingNumber("25011");
orderPermitDTO.setPermitSetType("Lot");
orderPermitDTO.setVendorEmailAddresses("xy@yahoo.com");
orderPermitDTO.setOrderNumber(new Integer(1001));


OrderPermitUnitDetailPK orderPermitUnitDetailPK =
new OrderPermitUnitDetailPK(new Integer(1001),"ab");

OrderPermitUnitDetail orderPermitUnitDetail
= new OrderPermitUnitDetail(orderPermitUnitDetailPK, "Nagesh", "Nag",
"test", "250", "junk", "done");

Set orderPermitUnitDetails = new HashSet();
orderPermitUnitDetail.setOrderPermitDTO(orderPermitDTO);
orderPermitUnitDetails.add(orderPermitUnitDetail);

Any help is appreciated.

Regards



Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 23, 2005 3:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Did you try reading the exception message?? I'm not sure what I can say to make that any clearer: just map the repeated column (OrderNumber) with insert=false update=false.


Top
 Profile  
 
 Post subject: I did the same. please find the code.
PostPosted: Sat Apr 23, 2005 3:32 pm 
Newbie

Joined: Sat Apr 02, 2005 10:32 am
Posts: 14
Hi

I did that that before posting, but it is not inserting into the child. It is simply inserting into the parent.
I am really struggling with this from last two days.
If you have any well-documented code/example, please send it to g_nagesh@novell.com

Regards
g_nagesh@novell.com


Top
 Profile  
 
 Post subject: two more points to the same question
PostPosted: Sat Apr 23, 2005 3:40 pm 
Newbie

Joined: Sat Apr 02, 2005 10:32 am
Posts: 14
1.when I added insert="false" update="false", I am getting the following exception

OrderPermitDTO.orderPermitUnitDetails -> orderpermitunitdetail
13:45:36,954 INFO [Configuration] processing association property references
13:45:36,954 INFO [Configuration] processing foreign key constraints
13:45:36,954 INFO [STDOUT] org.hibernate.MappingException: Repeated column in mapping for entity: c
om.tollbrothers.archonline.valueobjects.archdoc.OrderPermitUnitDetail column: OrderNumber (should be
mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:487)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java


2.and If i remove couple of tags then I was getting following errors

10:00:31,238 INFO [STDOUT] CRUD CREATE
10:00:31,278 INFO [STDOUT] Hibernate: insert into orderpermit (PermitOrderType, PermitSetType, IsAt
tached, AttachedBuildingNumber, IsQuickDeliveryHome, IsEmailDeliveryType, IsPrintDeliveryType, Vendo
rEmailAddresses, OrderNumber) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
10:00:31,288 INFO [STDOUT] Hibernate: update orderpermitunitdetail set ModelId=?, ElevationId=?, Bl
ockLotSection=?, StreetAddress=?, GradeElevation=?, FinishedFloorElevation=? where OrderNumber=? and
TBILotNumber=?
10:00:31,368 ERROR [AbstractBatcher] Exception executing batch:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual
row count: 0 expected: 1
at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:88)



Ideally, I want to apply insert statement in second table, but somehow it is preparing update statement. I am really wondering and I am missing couple of crucial concepts here.

anybody enlighten me?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 26, 2005 3:34 am 
Beginner
Beginner

Joined: Wed Apr 21, 2004 8:33 am
Posts: 27
I guess in your chjild mapping xml where you have defined many-to-one make insert=false and update=false also just check if the column name being mapped is correct.

thanks
yenne


Top
 Profile  
 
 Post subject: Thank u
PostPosted: Tue Apr 26, 2005 11:26 am 
Newbie

Joined: Sat Apr 02, 2005 10:32 am
Posts: 14
Thanks. Issue is resolved couple of days back. I missed the basic concept of cascade in mapping files. anyways, thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.