-->
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.  [ 2 posts ] 
Author Message
 Post subject: Repeated Column problem
PostPosted: Tue Mar 01, 2005 11:20 am 
Beginner
Beginner

Joined: Thu Oct 14, 2004 5:07 am
Posts: 37
Location: Cambridge, UK
Hi

I have a Cost table which is reused by 3 other tables that have Cost related information....

So I want to setup cascades from all 3 entities into this Cost table. The Cost table itself has a 'linking_id', which is to hold the primarykey of one of the three other entites....

It works fine if I only define one entity in the Cost.hbm.xml file, but as soon as I add the hbm defs for the other two entities I get:

[junit] Caused by: net.sf.hibernate.MappingException: Repeated column in mapping for class com.ocado.tracker.costs.pojo.Cost should be mapped with insert="false" update="false": linking_id


So, I add insert="false" to all three definitions, but then it bails saying linking_id is NULL (and cannot add with linking_id being NULL)...

I cannot manually set the linking_id as I do not yet have it from the parent entity (as I want to cascade add).....

I could probably get around the repeated column error, by changing linking_id into 3 cols, and hold a nullable id for each of the three entities... but this is not very pretty if other tables in the future want to use this...

Any ideas anyone? I am sure others have come across this?


Hibernate version:2.1.7

Mapping documents:

<many-to-one
name="incidents3pty"
class="com.ocado.tracker.incidents.pojo.Incidents3pty"
column="linking_id"
update="false"
cascade="none"
not-null="false"
outer-join="false"
/>

<many-to-one
name="fleetDefect"
class="com.ocado.tracker.defects.pojo.FleetDefect"
column="linking_id"
update="false"
cascade="none"
not-null="false"
outer-join="false"
/>

<many-to-one
name="offence"
class="com.ocado.tracker.offences.pojo.Offence"
column="linking_id"
update="false"
cascade="none"
not-null="false"
outer-join="false"
/>


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

Full stack trace of any exception that occurs:

Name and version of the database you are using:Oracle 9i

The generated SQL (show_sql=true):It does not get that far

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: Just seen this post
PostPosted: Tue Mar 01, 2005 11:41 am 
Beginner
Beginner

Joined: Thu Oct 14, 2004 5:07 am
Posts: 37
Location: Cambridge, UK
http://forum.hibernate.org/viewtopic.php?t=939232

and read the Hibernate view that this design is a broken data model... and not properly normalised...

So I will just normalise it properly...

Cheers


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