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.  [ 4 posts ] 
Author Message
 Post subject: one-to-one and MappingException: broken column mapping
PostPosted: Fri Oct 07, 2005 1:18 pm 
Beginner
Beginner

Joined: Tue Sep 27, 2005 2:51 pm
Posts: 27
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Any help would be greatly appriecated!

Prep: This is a fairly straight forward and common scenario. I have a model to support: An application within an environment on a server has properties and values for those properties such that I have the following tables
Application has keys
app_name
server_name
environment_id

Property has key
property_id

InstanceValues has key
value_id

appPropVal (relation between apps, properties and property values)has keys
app_name
server_name
environment_id
property_id
value_id

The following classes are defined
ApplicationImpl
Property
PropertyValue (contains one value)
AppProperty (contains 1 property and the values assigned)
AppPropValRelationshipKey (contains the composite-id info)

Hibernate version:3.0.5

Mapping documents:
AppProperty:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC       
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"         
"hibernate-mapping-3.0.dtd">
<hibernate-mapping schema="j3_foundations_dba" default-lazy="false" package="context">
   <class name="AppProperty" table="serv_env_app_prop_val">
   <composite-id name="appPropXref" class="AppPropValRelationshipKey">
   <key-property name="serverName" column="server_name"/>
   <key-property name="environment" column="environment_id"/>
      <key-property name="appName" column="app_name"/>         
   <key-property name="propertyId" column="property_id"/>
   <key-property name="propInstId" column="value_id"/>
   </composite-id>
   <property name="propValIsActiveC" type="character" column="is_active"/>         
   <property name="replaceDate" type="date" column="replace_date"/>         
   <property name="effectiveDate" type="date" column="effective_date"/>         

   <!-- join to the one property which is hooked up to this application -->
   <one-to-one name="proper" class="Property" lazy="false"
      constrained="false" fetch="select" formula="appPropXref.propertyId"
      foreign-key="proper.propertyId">
   </one-to-one>
   <!-- possible set of values which are hooked to this property which is hooked up to this application -->
    </class>
</hibernate-mapping>


Property
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping schema="j3_foundations_dba" package="context">
    <class name="Property" table="property">
        <id name="propertyId" column="property_id">
            <generator class="increment"/>
        </id>
        <property name="propName" type="string" column="property_name"/>
        <property name="propDesc" type="string" column="description"/>
        <property name="prefTypeId" type="integer" column="perf_type_id"/>
        <property name="propIsActive" type="character" column="is_active"/>
        <property name="depricationDate" type="calendar" column="depricate_date"/>
   </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Hurls on openSession when checking the mapping

Full stack trace of any exception that occurs:
Exception msg= Initial SessionFactory creation failed.org.hibernate.MappingException: broken column mapping for: proper.id of: AppProperty

Code:
Partial Stack
org.hibernate.MappingException: broken column mapping for: proper.id of: com.thomson.west.foundations.context.AppProperty
   at org.hibernate.persister.entity.AbstractPropertyMapping.initPropertyPaths(AbstractPropertyMapping.java:121)
   at org.hibernate.persister.entity.AbstractPropertyMapping.initIdentifierPropertyPaths(AbstractPropertyMapping.java:162)
   at org.hibernate.persister.entity.AbstractPropertyMapping.initPropertyPaths(AbstractPropertyMapping.java:146)
   at org.hibernate.persister.entity.BasicEntityPersister.initOrdinaryPropertyPaths(BasicEntityPersister.java:1395)
   at org.hibernate.persister.entity.BasicEntityPersister.initPropertyPaths(BasicEntityPersister.java:1423)
   at org.hibernate.persister.entity.BasicEntityPersister.postConstruct(BasicEntityPersister.java:2377)
   at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:375)
   at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:211)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
   at com.thomson.west.foundations.daos.HibernateUtil.<clinit>(HibernateUtil.java:43)
... on into my classes



Name and version of the database you are using:Oracle 10g

The generated SQL (show_sql=true):None

Debug level Hibernate log excerpt:

Code:

_________________
Dave Ziebol


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 07, 2005 1:31 pm 
Regular
Regular

Joined: Thu Jul 29, 2004 11:55 pm
Posts: 75
I think your mapping, at least for the foreign-key, should look like this:

<one-to-one name="proper" class="Property" lazy="false"
constrained="false" fetch="select" formula="appPropXref.propertyId"
foreign-key="property_id">
</one-to-one>

or whatever the name of the column is.


Top
 Profile  
 
 Post subject: one-to-one and MappingException: broken column mapping
PostPosted: Fri Oct 07, 2005 1:37 pm 
Beginner
Beginner

Joined: Tue Sep 27, 2005 2:51 pm
Posts: 27
ccanning wrote:
I think your mapping, at least for the foreign-key, should look like this:

<one-to-one name="proper" class="Property" lazy="false"
constrained="false" fetch="select" formula="appPropXref.propertyId"
foreign-key="property_id">
</one-to-one>

or whatever the name of the column is.


Thanks for replying, but unfortunately making this Change did not solve the problem.

_________________
Dave Ziebol


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 07, 2005 2:08 pm 
Newbie

Joined: Wed Aug 03, 2005 11:56 am
Posts: 7
Hi All,

I am also having same kind of problem. I need to perform left outer join with one to one relationship:

employee.hbm.xml
Code:
<hibernate-mapping package="mypackage">
    <class name="Employee" table="Employee">
        <composite-id name="key" class="EmpKey">
            <key-property name="deptId" column="DEPT_CODE" type="java.lang.String"/>
            <key-property name="empId" column="EMP_ID" type="java.lang.String"/>           
            <key-property name="certificationId" column="CERT_ID" type="java.lang.String"/>
        </composite-id>
        <property name="" ../>
        <property name="" ../>

        <one-to-one name="certification" class="Certification" property-ref="certificationId"/>
       
    </class>
</hibernate-mapping>


certification.hbm.xml

Code:

<hibernate-mapping package="mypackage">
    <class name="Certification" table="Certification">
        <id name="certificationId" column="CERT_ID" type="java.lang.String"/>

        <property name="certDesc" .../>
   ..
   ..
       
    </class>
</hibernate-mapping>


I am getting following exception while executing the query From Employee;
Code:

Initialization of bean failed; nested exception is org.hibernate.MappingException: property-ref not found: certificationId in class: mypackage.Certification



TIA,

Sanjay


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