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.  [ 1 post ] 
Author Message
 Post subject: What's the class name of cglib?
PostPosted: Tue Oct 12, 2004 2:31 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 6:15 am
Posts: 22
Hibernate version: 2.1

Mapping documents:
AssetImpl.hbm.xml
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>
    <class
        name="com.acme.AssetImpl"
        table="ACME_ASSET"
        proxy="com.acme.AssetORInterface"
        dynamic-update="true"
        dynamic-insert="true"
    >

        <id
            name="assetId"
            column="ASSET_ID"
            type="long"
        >
            <generator class="sequence">
                <param name="sequence">ACME_ASSET_ID_SQ</param>
            </generator>
        </id>

        <property
            name="assetDescription"
            type="string"
            update="true"
            insert="true"
            access="property"
            column="ASSET_DESCRIPTION"
            not-null="false"
            unique="false"
        />

        <set
            name="assetAttributesByAssetId"
            table="ACME_ASSET_ATTRIBUTE"
            lazy="true"
            inverse="true"
            cascade="none"
            sort="unsorted"
        >

              <key
              >
                <column
                    name="ASSET_ID"
                />
              </key>

              <one-to-many
                  class="com.acme.AssetAttributeImpl"
              />
        </set>


    </class>

</hibernate-mapping>


AssetAttributeImpl.hbm.xml
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>
    <class
        name="com.acme.AssetAttributeImpl"
        table="ACME_ASSET_ATTRIBUTE"
        proxy="com.acme.AssetAttributeORInterface"
        dynamic-update="true"
        dynamic-insert="true"
    >

        <id
            name="assetAttribute"
            column="ASSET_ATTRIBUTE_ID"
            type="long"
        >
            <generator class="sequence">
                <param name="sequence">ACME_ASSET_ATTRIBUTE_ID_SQ</param>
            </generator>
        </id>

        <many-to-one
            name="assetId"
            class="com.acme.AssetImpl"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="ASSET_ID"
        />

        <property
            name="attributeName"
            type="string"
            update="true"
            insert="true"
            access="property"
            column="ATTRIBUTE_NAME"
            not-null="true"
            unique="false"
        />

        <property
            name="attributeValue"
            type="string"
            update="true"
            insert="true"
            access="property"
            column="ATTRIBUTE_VALUE"
            not-null="false"
            unique="false"
        />

    </class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
Asset asset = (Asset)session.load(AssetImpl.class, new Long(1L));
Set s = asset.getAssetAttributesByAssetId();
Iterator it = s.iterator();
while (it.hasNext()) {
   AssetAttribute aa = (AssetAttribute)it.next();
   System.out.println(aa.getClass().getName());
}


Interface Asset is the super-interface of AssetORInterface. AssetAttribute is the super-interface of AssetAttributeORInterface.

Full stack trace of any exception that occurs:
None

Name and version of the database you are using:
Oracle 9i

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Hello,

From the code above, the classname printed is usually com.acme.AssetAttributeImpl. However, occasionally and randomly, I get com.acme.AssetAttributeORInterface$$EnhancerByCGLIB$$c8545bd8. It doesn't happen all the time.

I would appreciate it if someone can point out how and when CGLIB proxies the returned object.

Thanks a lot.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.