-->
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: Why can't I get the same with Hibernate.initialize!?
PostPosted: Sat Dec 20, 2003 7:16 pm 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
Why does my collection (misturaStocks) get loaded in:

res = session.find("from pt.comseal.arsol.vo.Mistura as m " +
"left join fetch m.misturaStocks " +
"where m.userId= '" + user + "'");

and not in:

Mistura m = (Mistura)session.get(Mistura.class, mistura.getId());
Hibernate.initialize(m.getMisturaStocks());


-----------------------------------------------------
Mapping file (generated with Middlegen R3)
-----------------------------------------------------

Mistura

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
   
<hibernate-mapping>
<!--
    Created by Middlegen Hibernate plugin

    http://boss.bekk.no/boss/middlegen/
    http://hibernate.sourceforge.net/
-->

<class
    name="vo.Mistura"
    table="mistura"
>

    <id
        name="id"
        type="long"
        column="id"
    >
        <generator class="increment" />
    </id>
   
    <property
        name="userId"
        type="java.lang.String"
        column="user_id"
        not-null="true"
        length="10"
    />

    <!-- associations -->
    <!-- bi-directional one-to-many association to MisturaStock -->
    <set
        name="misturaStocks"
        lazy="true"
        inverse="true"
    >
        <key>
            <column name="mistura_fk" />
        </key>
        <one-to-many
            class="vo.MisturaStock"
        />
    </set>

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 20, 2003 8:33 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
It should load.

How do you know it is not loaded? What is the diagnostics?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 20, 2003 9:22 pm 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
dimas wrote:
It should load.

How do you know it is not loaded? What is the diagnostics?


It was giving me the LazyInitializationException...
Now it's loading.

Thanks for the reply.


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.