-->
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: 2.1.8 proxy issue. Feeling like such a novice... sigh.
PostPosted: Wed Aug 31, 2005 10:43 am 
Regular
Regular

Joined: Tue Dec 09, 2003 2:39 pm
Posts: 106
Location: Toronto, Canada
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.1.8

Mapping documents:

Code:
<class
        name="com.acme.AttributeType"
        table="attribute_type"
        proxy="com.acme.AttributeType"
        dynamic-update="false"
        dynamic-insert="false"
        select-before-update="false"
    >
        <cache usage="nonstrict-read-write" />

        <id
            name="id"
            column="id"
            type="java.lang.String"
            unsaved-value="null"
        >
            <generator class="uuid.hex">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-AttributeType.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <map
            name="names"
            table="attribute_type_name"
            lazy="false"
            sort="unsorted"
            inverse="false"
            cascade="all"
        >

              <key
                  column="attribute_type_id"
              >
              </key>

              <index
                  column="locale_id"
                  type="string"
              />

              <element
                  column="translation"
                  type="string"
                  not-null="false"
                  unique="false"
              />

        </map>

        <map
            name="descriptions"
            table="attribute_type_description"
            lazy="false"
            sort="unsorted"
            inverse="false"
            cascade="all"
        >

              <key
                  column="attribute_type_id"
              >
              </key>

              <index
                  column="locale_id"
                  type="string"
              />

              <element
                  column="translation"
                  type="string"
                  not-null="false"
                  unique="false"
              />

        </map>

        <property
            name="keyCode"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="key_code"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-AttributeType.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>




Code between sessionFactory.openSession() and session.close():

Code:
session.find("from AttributeType");


Full stack trace of any exception that occurs:

Name and version of the database you are using: SQL Server 2000

The problem I am having is that despite the finder retrieving the list of AttributeTypes, and correct SQL is generated as I can see it in the SQL profiler, the returned AttributeTypes are the enhanced CGLIB proxies and not the initialized AttributeTypes.

Code:
AttributeType$$EnhancerByCGLIB$$


This is a pretty basic operation that I've done in the past many many times. However, on this occassion something (I'm sure that it is fundamental) is disallowing the entity from being correctly initialized.

If I iterate over the list and individually Hibernate.initialize or access a property the AttributeTypes are initialized. However, this shouldn't be the case, they should have been initialized immediatley upon return of the finder.

Please advise.

Roll


Top
 Profile  
 
 Post subject: Re: 2.1.8 proxy issue. Feeling like such a novice... sigh.
PostPosted: Wed Aug 31, 2005 11:01 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Are you certain you haven't upgraded to Hibernate 3 ?

Lazy Initialization is the default in H3.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject: Definitley 2.1.8
PostPosted: Wed Aug 31, 2005 11:05 am 
Regular
Regular

Joined: Tue Dec 09, 2003 2:39 pm
Posts: 106
Location: Toronto, Canada
Definitley using 2.1.8 although plans to migrate are being reviewed for next release.

Despite using lazy proxies, if I'm issuing a session.find(from EntityName) shouldn't this return the initialized list of entities?

We're not talking lazy associations or collections. This is the primary entity being queried.


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.