-->
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: Bug HibernateToolTask with parent child to composite-element
PostPosted: Thu Oct 27, 2005 12:47 pm 
Beginner
Beginner

Joined: Sun Oct 09, 2005 3:21 pm
Posts: 40
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.1.0 (Hibernate Tools 3.1.0 beta1)

Mapping documents:
Code:
  <class name="Resurs" table="RESURS">

        <id name="id" column="RESURSID">
                <generator class="identity">
                </generator>
        </id>

        <many-to-one name="typ" class="Resurstyp" property-ref="typ" foreign-key="FK_RESURSRESURSTYP">
                <column name="RESURSTYP" length="50" not-null="true"/>
        </many-to-one>

        <property name="beteckning">
                <column name="BETECKNING" length="50" not-null="true"/>
        </property>

        <set name="resurser" table="RELRESURS">
                <key column="RESURSID1" not-null="true" foreign-key="FK_RELRESURSID1"/>
                <composite-element class="RelResurs">
                        <parent name="resursid1"/>
                        <many-to-one name="resursid2" column="RESURSID2" not-null="true" class="Resurs" foreign-key="FK_RELRESURSID2"/>
                        <property name="fromdatum" length="50" not-null="true"/>
                        <property name="tomdatum" length="50"/>
                </composite-element>
        </set>

  </class>



Name and version of the database you are using: MySql 5.0.13


Running the mapping document above through the HibernateToolTask to generate Java POJO classes I expected that the parent element would result in a property named "resursid1" of type "Resurs" in the resulting "RelResurs" class. But the setter/getter methods are never writen which causes the following exception to be thrown:

Code:
Caused by: org.hibernate.PropertyNotFoundException: Could not find a setter for property resursid1 in class RelResurs


How can composite-element classes be used if they don't mirror the columns in the underlying table?


Top
 Profile  
 
 Post subject: Re: Bug HibernateToolTask with parent child to composite-ele
PostPosted: Fri Oct 28, 2005 4:46 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
young_matthewd wrote:
How can composite-element classes be used if they don't mirror the columns in the underlying table?

Knowledge of relationships is in mapping files and therefore mirroring is not necessary. The fact that an object is in collection property of a parent element is enough for H to know that the object has to be persisted in a row that has to have FK column. And for retrieval the FK column is just a criterion.

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 28, 2005 5:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
double posting is not appreciated...

_________________
Max
Don't forget to rate


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.