-->
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: Broken column mapping
PostPosted: Fri Mar 06, 2009 6:02 am 
Beginner
Beginner

Joined: Thu Feb 19, 2009 5:48 am
Posts: 37
Location: Glasgow, Scotland
I've seen this issue a few times on the board but nothing like what I am experiencing, any help please?


Mapping documents:
Code:
<!-- Capabilities -->   
    <class name="edina.clive.domain.Capabilities" table="services">
    <meta attribute="class-description">
      The main class holding a layer object (further layers held inside this layer objects sub layers)
    </meta>
        
        <id name="productName">
            <generator class="assigned"/>
        </id>
       
      <!-- serviceTitle?? -->
       
<!-- TODO: How do to this avoiding one-to-one and not insinuating a set -->
<!--
      <set name="layers" table="LAYERS">
         <key>
            ## <column name="layerName" /> ##
            <column name="productName" />
         </key>
          <one-to-many class="edina.clive.domain.Layer" />
       </set>-->
   <one-to-one name="layers" class="edina.clive.domain.Layer" />
       
        <property name="capabilities" column="capabilitiesurl"/>
        <property name="mapURL"/>
        <property name="featureURL"/>
        <property name="printURL"/>
        <property name="cohabitable"/>
        <property name="customVendorSpecificAttributes" column="vendorspecific"/>       
    </class>
   
<!-- Layer -->
    <class name="edina.clive.domain.Layer" table="layers">
    <meta attribute="class-description">
      A layer object which holds a list of layer sub-objects and a list of Style names in place of a style object
    </meta>

    <!--  also db column layerbbox -->
        <composite-id>
           <key-property name="layerName" />
           <key-property name="productName"/>
        </composite-id>
       
       <property name="subLayers" column="subLayers" type="edina.clive.domain.hibernate.SubLayerUserType"/>
       
   <!-- TODO: Envelope -->
      
       <!-- it may be possible to do this the originally intended way (having two comma separated fields in the Layer table and building from them) -->
       <set name="styles" table="STYLES">
         <key>
            <column name="styleName" />
            <column name="styleTitle" />
         </key>
          <one-to-many class="edina.clive.domain.Style" />
       </set>
      
      <property name="layerTitle" />
      <property name="srs" column="layerSRS" />
      <property name="minimumScale" column="layerscalemin"/>
      <property name="maximumScale" column="layerscalemax"/>
    </class>


Full stack trace of any exception that occurs:
Code:
Exception in thread "main" org.hibernate.MappingException: broken column mapping for: layers.id of: edina.clive.domain.Capabilities
   at org.hibernate.persister.entity.AbstractPropertyMapping.initPropertyPaths(AbstractPropertyMapping.java:121)
   at org.hibernate.persister.entity.AbstractPropertyMapping.initIdentifierPropertyPaths(AbstractPropertyMapping.java:177)
   at org.hibernate.persister.entity.AbstractPropertyMapping.initPropertyPaths(AbstractPropertyMapping.java:159)
   at org.hibernate.persister.entity.AbstractEntityPersister.initOrdinaryPropertyPaths(AbstractEntityPersister.java:1712)
   at org.hibernate.persister.entity.AbstractEntityPersister.initPropertyPaths(AbstractEntityPersister.java:1742)
   at org.hibernate.persister.entity.AbstractEntityPersister.postConstruct(AbstractEntityPersister.java:2919)
   at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:409)
   at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
   at edina.clive.dao.DatabaseCapabilitiesDAO.main(DatabaseCapabilitiesDAO.java:147)

_________________
##############################
If I helped, rate my comment, I have plenty of stupid questions to ask that I need credit for ;)
##############################


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 06, 2009 6:39 am 
Beginner
Beginner

Joined: Thu Feb 19, 2009 5:48 am
Posts: 37
Location: Glasgow, Scotland
Also, if I change the Capabilities->Layer relation to


Code:
<many-to-one name="layers" class="edina.clive.domain.Layer">
      <column name="layerName"/>
      <column name="productName"/><!-- REPEATED COLUMN --> </many-to-one>



I get a repeated column error because (I think) productName is part of the natural primary key of Capabilities, and instructs me to do this

Code:
<many-to-one name="layers" class="edina.clive.domain.Layer" insert="false" update="false">
      <column name="layerName"/>
      <column name="productName"/>
</many-to-one>


Which then doesn't update anything in the database except the Capabilities object![/code]

_________________
##############################
If I helped, rate my comment, I have plenty of stupid questions to ask that I need credit for ;)
##############################


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 06, 2009 7:31 pm 
Regular
Regular

Joined: Tue Dec 30, 2008 8:14 pm
Posts: 50
Can you use property-ref for the "layerName" in Capabilities.

LinHib.


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.