-->
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.  [ 3 posts ] 
Author Message
 Post subject: CompositeId & Discriminator - Repeated column in mapping
PostPosted: Tue Jan 16, 2007 9:24 am 
Newbie

Joined: Tue Jan 16, 2007 8:58 am
Posts: 17
Hibernate version: 3

I've been trying to create a mapping to a class which has a composite key. One of the columns of this key is also a discriminator.

Mapping file
Code:
<hibernate-mapping>
   <class name="Label" table="Label" discriminator-value="0" abstract="true">
      <composite-id name="id" class="SerialNumberId">
            <key-property name="typeLabel" type="short">
                <column name="typeLabel" />
            </key-property>
            <key-property name="serialNumber" type="long">
                <column name="serialNumber" />
            </key-property>
        </composite-id>

      <discriminator column="typeLabel" type="short"/>

      <subclass name="LabelBox"
         discriminator-value="2">
      </subclass>
   </class>
</hibernate-mapping>



When using this mapping, I always end up with this error:org.hibernate.MappingException: Repeated column in mapping for entity: LabelBox column: typeLabel (should be mapped with insert="false" update="false")

Here is the full exception stack trace:
org.hibernate.MappingException: Repeated column in mapping for entity: LabelBox column: typeLabel (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:590)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:629)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:405)
at org.hibernate.mapping.SingleTableSubclass.validate(SingleTableSubclass.java:43)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1026)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
at org.hibernate.console.ConsoleConfiguration$2.execute(ConsoleConfiguration.java:282)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:56)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:85)
at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:277)
at org.hibernate.eclipse.console.workbench.LazySessionFactoryAdapter.getChildren(LazySessionFactoryAdapter.java:41)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.getChildren(BasicWorkbenchAdapter.java:88)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:94)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:207)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)


Is there any way to achieve composite-id + discriminator + subclass ? I don't want to create 2 tables in my database...

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 16, 2007 9:43 am 
Newbie

Joined: Tue Dec 12, 2006 9:07 am
Posts: 13
Did you try doing what the exception suggests ? marking the descriminator with insert=false, update=false. We have faced this kind of exception when two properties are mapped to the same database column , one in composite-key and the other mapped independently.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 16, 2007 11:58 am 
Newbie

Joined: Tue Jan 16, 2007 8:58 am
Posts: 17
I was just testing that. I found the insert for discriminator but not the update. I guess that was confusing me.

Works fine. thanks


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