-->
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.  [ 5 posts ] 
Author Message
 Post subject: Error with complex mapping containing object w/ simple mappi
PostPosted: Wed Oct 01, 2003 5:46 pm 
Newbie

Joined: Tue Sep 30, 2003 7:10 pm
Posts: 10
I'm refining down the trouble I mentioned in another thread.

The first mapping below works fine. The second mapping fails. Note the only different is that "ValueObject" has a simple map added to it. Can anyone explain why this fails?

Quote:
Schema text failed: Problem trying to set property
type by reflection: Could not find a getter for stuff in class ValueObject


This mapping works fine:
Code:

    <class name="KeyObject" table="ko">
        <id name="id" type="string" unsaved-value="null" >
            <column name="id" sql-type="char(32)" not-null="true"/>
            <generator class="uuid.hex"/>
        </id>
        <property name="name" type="string" not-null="true"/>
        <property name="someField" type="string" not-null="true"/>

    </class>

    <class name="ValueObject" table="vo">
        <id name="id" type="string" unsaved-value="null" >
            <column name="id" sql-type="char(32)" not-null="true"/>
            <generator class="uuid.hex"/>
        </id>
        <property name="name" type="string" not-null="true"/>
        <property name="someOtherField" type="string" not-null="true"/>
    </class>

    <class name="MapClass" table="mc">
        <id name="id" type="string" unsaved-value="null" >
            <column name="id" sql-type="char(32)" not-null="true"/>
            <generator class="uuid.hex"/>
        </id>
        <map name="kvMapping" lazy="true" >
            <key column="id"/>
            <composite-index class="KeyObject" >
                <key-property name="name"/>
                <key-property name="someField"/>
            </composite-index>
            <composite-element class="ValueObject" />

        </map>

        <property name="name" type="string" not-null="true"/>
        <property name="someOtherField" type="string" not-null="true"/>
    </class>


2nd mapping, fails:

Code:
    <class name="KeyObject" table="ko">
        <id name="id" type="string" unsaved-value="null" >
            <column name="id" sql-type="char(32)" not-null="true"/>
            <generator class="uuid.hex"/>
        </id>
        <property name="name" type="string" not-null="true"/>
        <property name="someField" type="string" not-null="true"/>

    </class>

    <class name="ValueObject" table="vo">
        <id name="id" type="string" unsaved-value="null" >
            <column name="id" sql-type="char(32)" not-null="true"/>
            <generator class="uuid.hex"/>
        </id>
        <property name="name" type="string" not-null="true"/>
        <property name="someOtherField" type="string" not-null="true"/>
        <map name="stuff" lazy="true" >
            <key column="id"/>
            <index column="key" type="string"/>
            <element column="value" type="string"/>
        </map>
    </class>

    <class name="MapClass" table="mc">
        <id name="id" type="string" unsaved-value="null" >
            <column name="id" sql-type="char(32)" not-null="true"/>
            <generator class="uuid.hex"/>
        </id>
        <map name="kvMapping" lazy="true" >
            <key column="id"/>
            <composite-index class="KeyObject" >
                <key-property name="name"/>
                <key-property name="someField"/>
            </composite-index>
            <composite-element class="ValueObject" />

        </map>

        <property name="name" type="string" not-null="true"/>
        <property name="someOtherField" type="string" not-null="true"/>
    </class>
Quote:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 01, 2003 9:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Does your ValueObject class have a method defined as
Code:
public java.util.Map getStuff() { ... }


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 02, 2003 10:39 am 
Newbie

Joined: Tue Sep 30, 2003 7:10 pm
Posts: 10
steve wrote:
Does your ValueObject class have a method defined as
Code:
public java.util.Map getStuff() { ... }


I'm using hbm2java. Hibernate is creating the java object ValueObject. Perhaps hibernate is not making that method?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 02, 2003 10:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Only one way to find out...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 02, 2003 1:34 pm 
Newbie

Joined: Tue Sep 30, 2003 7:10 pm
Posts: 10
steve wrote:
Only one way to find out...


Looking at the generated code, ValueObject does not have the getter. In fact, it has no fields in it. If I comment out MapClass entirely, all the fields in ValueObject show up as expected. (with the right getters/setters)

So I guess what is happening is the <composite-element> in MapClass' kvMapping is creating a whole new class called ValueObject which overwrites the real ValueObject.

So then: How do I get the element in MapClass' kvMapping to point at the (real) ValueObject type? What am I doing wrong?


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