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.