-->
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.  [ 5 posts ] 
Author Message
 Post subject: Exception initializing proxy
PostPosted: Wed Sep 03, 2003 7:24 pm 
Newbie

Joined: Thu Aug 28, 2003 11:49 am
Posts: 15
Location: Calgary, Alberta, Canada
Mappings:
Code:
<class name="com.envistatech.dbcompare.Column" mutable="false" proxy="com.envistatech.dbcompare.Column" table="user_tab_cols">
    <composite-id>
        <key-property name="tableName" column="table_name" length="30" type="string"/>           
        <key-property name="name" column="column_name" type="string" length="30" />       
    </composite-id>
    <one-to-one name="comment" class="com.envistatech.dbcompare.ColumnComment" constrained="true" outer-join="true"/>
</class>

<class name="com.envistatech.dbcompare.ColumnComment" mutable="false" proxy="com.envistatech.dbcompare.ColumnComment" table="user_col_comments">
    <composite-id>
        <key-property name="tableName" column="table_name" length="30" type="string"/>           
        <key-property name="name" column="column_name" length="30" type="string"/>       
    </composite-id>
    <property name="text" column="comments" length="4000" not-null="false" type="string"/>
</class>


Code:
Code:
Iterator i = session.iterate("from Column as c where c.tableName = 'ANALYTES'");
while (i.hasNext()) {
    Column column = (Column) i.next();
    System.out.println(column.getComment().getText());
}


Exception:
Code:
Sep 3, 2003 5:16:57 PM net.sf.hibernate.proxy.LazyInitializer initializeWrapExceptions
SEVERE: Exception initializing proxy
java.lang.ClassCastException
   at com.envistatech.dbcompare.ColumnCommentMetaClass0.getPropertyValues(<generated>)
   at net.sf.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:197)
   at net.sf.hibernate.type.ComponentType.nullSafeGetValues(ComponentType.java:171)
   at net.sf.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:158)
   at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:494)
   at net.sf.hibernate.loader.Loader.doFind(Loader.java:136)
   at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:587)
   at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42)
   at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:396)
   at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1889)
   at net.sf.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:1698)
   at net.sf.hibernate.proxy.LazyInitializer.initialize(LazyInitializer.java:47)
   at net.sf.hibernate.proxy.LazyInitializer.initializeWrapExceptions(LazyInitializer.java:54)
   at net.sf.hibernate.proxy.LazyInitializer.getImplementation(LazyInitializer.java:152)
   at net.sf.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:55)
   at com.envistatech.dbcompare.ColumnComment$$EnhancedByCGLIB$$2.getText(<generated>)
   at com.envistatech.dbcompare.MappingTest.testColumnCommentThroughColumn(MappingTest.java:64)
   [... Stack snipped by me ...]
rethrown as net.sf.hibernate.PropertyAccessException: exception getting property value with CGLIB getter of com.envistatech.dbcompare.ColumnComment.?
   at net.sf.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:200)
   at net.sf.hibernate.type.ComponentType.nullSafeGetValues(ComponentType.java:171)
   at net.sf.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:158)
   at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:494)
   at net.sf.hibernate.loader.Loader.doFind(Loader.java:136)
   at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:587)
   at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42)
   at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:396)
   at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1889)
   at net.sf.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:1698)
   at net.sf.hibernate.proxy.LazyInitializer.initialize(LazyInitializer.java:47)
   at net.sf.hibernate.proxy.LazyInitializer.initializeWrapExceptions(LazyInitializer.java:54)
   at net.sf.hibernate.proxy.LazyInitializer.getImplementation(LazyInitializer.java:152)
   at net.sf.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:55)
   at com.envistatech.dbcompare.ColumnComment$$EnhancedByCGLIB$$2.getText(<generated>)
   at com.envistatech.dbcompare.MappingTest.testColumnCommentThroughColumn(MappingTest.java:64)
    [... Stack snipped by me ...]
Caused by: java.lang.ClassCastException
   at com.envistatech.dbcompare.ColumnCommentMetaClass0.getPropertyValues(<generated>)
   at net.sf.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:197)
   ... 30 more


What am I doing wrong? I can query ColumnComment directly without a problem. I'm generating the Java classes using Hbm2Java... This is going against Oracle. thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 03, 2003 9:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This exception usually occurs when your object property type does not match the mapping. Disable the CGLIB reflection optimizer to get more useful information.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2003 11:41 am 
Newbie

Joined: Thu Aug 28, 2003 11:49 am
Posts: 15
Location: Calgary, Alberta, Canada
gavin wrote:
This exception usually occurs when your object property type does not match the mapping. Disable the CGLIB reflection optimizer to get more useful information.


I disabled the reflection optimizer and get this now:

Code:
Sep 4, 2003 9:32:09 AM net.sf.hibernate.util.ReflectHelper$Getter get
SEVERE: IllegalArgumentException in class: com.envistatech.dbcompare.ColumnComment, getter method of property: tableName
Sep 4, 2003 9:32:09 AM net.sf.hibernate.proxy.LazyInitializer initializeWrapExceptions
SEVERE: Exception initializing proxy
java.lang.IllegalArgumentException: object is not an instance of declaring class
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at net.sf.hibernate.util.ReflectHelper$Getter.get(ReflectHelper.java:99)
   at net.sf.hibernate.type.ComponentType.getPropertyValue(ComponentType.java:186)
   at net.sf.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:206)
   at net.sf.hibernate.type.ComponentType.nullSafeGetValues(ComponentType.java:171)
   at net.sf.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:158)
   at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:494)
   at net.sf.hibernate.loader.Loader.doFind(Loader.java:136)
   at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:587)
   at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:42)
   at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:396)
   at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1889)
   at net.sf.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:1698)
   at net.sf.hibernate.proxy.LazyInitializer.initialize(LazyInitializer.java:47)
   at net.sf.hibernate.proxy.LazyInitializer.initializeWrapExceptions(LazyInitializer.java:54)
   at net.sf.hibernate.proxy.LazyInitializer.getImplementation(LazyInitializer.java:152)
   at net.sf.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:55)
   at com.envistatech.dbcompare.ColumnComment$$EnhancedByCGLIB$$2.getText(<generated>)
   at com.envistatech.dbcompare.MappingTest.testColumnCommentThroughColumn(MappingTest.java:65)
        [Stack snipped here...]


I'm not really sure what to make of this. The column types seem to match the mapping which match the generated Java classes. They're all Strings. (BTW: I'm using 2.0.3)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2003 11:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
OH, didn't notice the one-to-one mapping.


A one-to-one mapping requires that both classes have the same identifier type. Since you are using an "embedded" composite id, they don't in this case.


Use a composite id class, as recommended in Hibernate documentation.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2003 12:01 pm 
Newbie

Joined: Thu Aug 28, 2003 11:49 am
Posts: 15
Location: Calgary, Alberta, Canada
Excellent. Thanks again.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.