-->
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: mapping issues in two tables... just plain weird
PostPosted: Wed Feb 11, 2004 3:26 pm 
Newbie

Joined: Wed Jan 21, 2004 2:20 pm
Posts: 3
I apologize in advance if the answer to this turns out to be in the docs, but in two days of looking I haven't found anything on this.

We have two tables, Surcharge and SurchargeDetail, where many surcharges can have the same surcharge detail.

When I run this snippet of code:
Code:
Criteria crit   = session.createCriteria( SurchargeDetail.class );
crit.add( Expression.eq( "comp_id.surcharge.currentRow", "Y" ));
List list = crit.list();

I get the following error:
Quote:
TRAS0014I: The following exception was logged net.sf.hibernate.QueryException: could not resolve property: comp_id.surcharge.currentRow of: com.mydomain.db.bo.SurchargeDetail


This is odd since if I change the criteria expression field to
Code:
comp_id.surcharge.comp_id.surchargeId
it works. Anyone have a direction they could point me in to figure this out?

Relevant snippets of my mapping files are listed below, and were generated by Middlegen. I can post the .java files if need be, but they
are exactly what hbm2java generates from these mappings files.

Thanks,
Steve

Code:
<class
    name="com.mydomain.db.bo.SurchargeDetail"
    table="SURCHGDTL"
    schema="PRICE"
>

    <composite-id name="comp_id" class="com.mydomain.db.bo.SurchargeDetailPK">
        <key-property
            name="year"
            column="YR"
            type="java.lang.Integer"
            length="10"
        />
        <key-property
            name="month"
            column="MO"
            type="java.lang.Integer"
            length="10"
        />
        <!-- bi-directional many-to-one association to Surcharge -->
        <key-many-to-one
           name="surcharge"
           class="com.mydomain.db.bo.Surcharge"
       >
           <column name="CATCD" />
           <column name="SURCHGID" />
           <column name="EFFTS" />
       </key-many-to-one>
    </composite-id>   

    <timestamp
        name="updateTimestamp"
        column="UPDTS"
    />

    <property
        name="baseDollarAmount"
        type="java.math.BigDecimal"
        column="BASEDOL"
        not-null="true"
        length="12"
    />


And...

Code:
<class
    name="com.mydomain.db.bo.Surcharge"
    table="SURCHG"
    schema="PRICE"
>

    <composite-id name="comp_id" class="com.mydomain.db.bo.SurchargePK">
        <key-property
            name="surchargeCategory"
            column="CATCD"
            type="com.mydomain.db.TrimmedString"
            length="1"
        />
        <key-property
            name="surchargeId"
            column="SURCHGID"
            type="com.mydomain.db.TrimmedString"
            length="10"
        />
        <key-property
            name="effectiveTimestamp"
            column="EFFTS"
            type="java.sql.Timestamp"
            length="26"
        />
    </composite-id>   

    <timestamp
        name="lastUpdateTimestamp"
        column="UPDTS"
    />

    <property
        name="currentRow"
        type="com.mydomaing.db.TrimmedString"
        column="CURRIND"
        not-null="true"
        length="1"
    />


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 5:23 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Criteria queries do not currently support <key-many-to-one>. Fixing this is on the TODO list. Sorry.


Top
 Profile  
 
 Post subject: whew!
PostPosted: Wed Feb 11, 2004 5:53 pm 
Newbie

Joined: Wed Jan 21, 2004 2:20 pm
Posts: 3
Thanks gavin,
I can live with that. It's nice to know I'm not completely crazy.


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.