-->
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: issue using FetchMode.join
PostPosted: Sun Jun 19, 2011 2:04 pm 
Newbie

Joined: Sat May 19, 2007 5:56 am
Posts: 5
hi,

We have tables similar to Payment{id, col1, col2} (Table1.id is primary key; auto increment one)

PaymentAmount{payment_id,transaction_status, col1, col2... } (PaymentAmount.payment_id references Payment.id; [id, status] together form the pk for PaymentAmount;

Now, I have the hibernate mappings auto generated by eclipse plugin;

Code:
Payment{
Integer               id;
...
Set<PaymentAmountId> paymentAmount;
.. setters and getters
}

PaymentAmount{
public class PaymentAmount implements java.io.Serializable {
   private PaymentAmountId   id;
   private Payment         envPayment;
.. setters and getters;
}


When using criteria queries, I use the below code:
Code:
         List list = s.createCriteria(Payment.class)
            .add( Restrictions.eq("id", 1) )
            .setFetchMode("paymentAmounts", FetchMode.JOIN)
            .list();



What i see is Set<PaymentAmount> is always empty; THe sql stmt generated when run in Toad regturns a valid tuple containing payment and paymentAmount;

the HBM files are as follows:

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">
<!-- Generated 19 Jun, 2011 9:27:06 PM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
    <class name="com.company.Payment" table="payment" catalog="cashier">
        <id name="id" type="java.lang.Integer">
            <column name="id" />
            <generator class="identity" />
        </id>
        <many-to-one name="BankDetails" class="com.company.BankDetails" fetch="select">
            <column name="bank_details" />
        </many-to-one>
...
...
        <bag name="PaymentAmounts" table="payment_amount" inverse="true" lazy="true" fetch="select" cascade="all" >
            <key>
                <column name="payment_id" not-null="true" />
            </key>
            <one-to-many class="com.company.PaymentAmount" />
        </bag>
    </class>
</hibernate-mapping>


and

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">
<!-- Generated 19 Jun, 2011 9:27:06 PM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
    <class name="com.company.PaymentAmount" table="payment_amount" catalog="cashier">
        <composite-id name="id" class="com.company.PaymentAmountId">
            <key-property name="paymentId" type="int">
                <column name="payment_id" />
            </key-property>
         ...
         ...
            <key-property name="transactionType" type="string">
                <column name="transaction_type" length="7" />
            </key-property>
         ...
         ...
        </composite-id>
        <many-to-one name="Payment" class="com.company.Payment" update="false" insert="false" fetch="select">
            <column name="payment_id" not-null="true" />
        </many-to-one>
    </class>
</hibernate-mapping>



Any ideas where i m doing mistake? Any help?

-regards,
ravi


Top
 Profile  
 
 Post subject: Re: issue using FetchMode.join
PostPosted: Tue Jun 21, 2011 1:06 am 
Newbie

Joined: Sat May 19, 2007 5:56 am
Posts: 5
any update? I am blocked on this.

Any pointers?

I see hibernate examples but they have the set doesnt have a composite key -which is my case;


Top
 Profile  
 
 Post subject: Re: issue using FetchMode.join
PostPosted: Thu Jun 23, 2011 2:12 am 
Newbie

Joined: Sat May 19, 2007 5:56 am
Posts: 5
i am trying very hard but this one never works?

Havent anybody faced this issue? Am I the first fellow?

Any pointers / thoughts would be a great help


Top
 Profile  
 
 Post subject: Re: issue using FetchMode.join
PostPosted: Tue Jun 28, 2011 1:29 am 
Newbie

Joined: Sat May 19, 2007 5:56 am
Posts: 5
any update please :(


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.