Hi all,
I am posting here because did not found a place to report bugs.
Well, there comes:
I am using getRecursiveProperty(String propertyPath) because i am building a database component suite, using hibernate and Swing.
When i try to retrieve an property of Modelo class (categoria.descricao) with getRecursiveProperty, it raises a java.lang.ClassCastException
Because documentation of this method is poor (or none) , i decided debug the source, and found the exact point (Line 356 on PersistentClass.java):
//flat recursive algorithm
property = ( (Component) property.getValue() ).getProperty(element);
i am not sure, but i think (IMHO) the line should be changed to :
//flat recursive algorithm
property = property.getPersistentClass().getProperty(element);
Congratulations by this powerfull framework, and sorry by my poor english.
regards,
Carlos A. C. de Lima ( MacLeod )
Hibernate version:
3.1
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="br.com.highlands.extasy.model.inventario.Categoria">
<!-- Identificador da classe -->
<id name="idcategoria">
<generator class="native"/>
</id>
<!-- Propriedades da classe -->
<property name="descricao"/>
<many-to-one name="categoriapai" column= "idcategoriapai"/>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="br.com.highlands.extasy.model.inventario.Modelo">
<!-- Identificador da classe -->
<id name="idmodelo">
<generator class="native"/>
</id>
<!-- Propriedades da classe -->
<property name="codigo"/>
<property name="descricao"/>
<many-to-one name="categoria" class="br.com.highlands.extasy.model.inventario.Categoria" column= "idcategoria"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
PersistentClass persistentClass = HibernateFactory.getConfiguration().getClassMapping(Modelo.class.getName());
Property p = persistentClass.getRecursiveProperty("categoria.descricao");
Full stack trace of any exception that occurs:
java.lang.ClassCastException
at org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:356)
at org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:334)
at br.com.highlands.extasy.hibernate.MappingUtils.getPropertyMapping(MappingUtils.java:22)
at br.com.highlands.extasy.NewJFrame.criaGrid(NewJFrame.java:144)
at br.com.highlands.extasy.NewJFrame.<init>(NewJFrame.java:54)
at br.com.highlands.extasy.NewJFrame.main(NewJFrame.java:47)
|