i'm very happy with hibernate, but i'm fighting with a problem since i started the development of my application.
i think it's concerned whit the session but i'm not sure...
i'm using spring as helper to use the open-session-inview pattern
and mysql as db.
i've an entity that has a string as pk,
some queries on that entity give me trouble
here is the error i get setting in the configuration file for that entity the access to the field by the getter method:
ERROR BasicPropertyAccessor:167 - IllegalArgumentException in class: it.infocamere.ged.entity.Classifica, getter method of property: guid
and also looking inside with the debbugger:"object is not an instance of declaring class"
while accessing the field directly, i obtain:
org.hibernate.PropertyAccessException: could not get a field value by reflection getter of it.infocamere.ged.entity.Classifica.guid
this is the stack trace:
Thread [main] (Suspended (breakpoint at line 35 in DirectPropertyAccessor$DirectGetter))
DirectPropertyAccessor$DirectGetter.get(Object) line: 35
PojoEntityTuplizer(AbstractEntityTuplizer).getIdentifier(Object) line: 183
SingleTableEntityPersister(AbstractEntityPersister).getIdentifier(Object, EntityMode) line: 3589
SingleTableEntityPersister(AbstractEntityPersister).isTransient(Object, SessionImplementor) line: 3305
ForeignKeys.isTransient(String, Object, Boolean, SessionImplementor) line: 181
ForeignKeys.getEntityIdentifierIfNotUnsaved(String, Object, SessionImplementor) line: 218
ManyToOneType(EntityType).getIdentifier(Object, SessionImplementor) line: 397
ManyToOneType.nullSafeSet(PreparedStatement, Object, int, SessionImplementor) line: 87
CriteriaLoader(Loader).bindPositionalParameters(PreparedStatement, QueryParameters, int, SessionImplementor) line: 1707
CriteriaLoader(Loader).bindParameterValues(PreparedStatement, QueryParameters, int, SessionImplementor) line: 1678
CriteriaLoader(Loader).prepareQueryStatement(QueryParameters, boolean, SessionImplementor) line: 1563
CriteriaLoader(Loader).doQuery(SessionImplementor, QueryParameters, boolean) line: 673
CriteriaLoader(Loader).doQueryAndInitializeNonLazyCollections(SessionImplementor, QueryParameters, boolean) line: 236
CriteriaLoader(Loader).doList(SessionImplementor, QueryParameters) line: 2220
CriteriaLoader(Loader).listIgnoreQueryCache(SessionImplementor, QueryParameters) line: 2104
CriteriaLoader(Loader).list(SessionImplementor, QueryParameters, Set, Type[]) line: 2099
CriteriaLoader.list(SessionImplementor) line: 94
SessionImpl.list(CriteriaImpl) line: 1569
CriteriaImpl.list() line: 283
FascicoloDaoHib$4.doInHibernate(Session) line: 315
HibernateTemplate.execute(HibernateCallback, boolean) line: 372
HibernateTemplate.execute(HibernateCallback) line: 338
FascicoloDaoHib.ricercaFascicoli(CriteriRicercaFascicolo, int, int) line: 318
RicercaFascicoliTest.test() line: 49
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 585
RicercaFascicoliTest(TestCase).runTest() line: 154
RicercaFascicoliTest(TestCase).runBare() line: 127
TestResult$1.protect() line: 106
TestResult.runProtected(Test, Protectable) line: 124
TestResult.run(TestCase) line: 109
RicercaFascicoliTest(TestCase).run(TestResult) line: 118
TestSuite.runTest(Test, TestResult) line: 208
TestSuite.run(TestResult) line: 203
JUnit3TestReference.run(TestExecution) line: 130
TestExecution.run(ITestReference[]) line: 38
RemoteTestRunner.runTests(String[], String, TestExecution) line: 460
RemoteTestRunner.runTests(TestExecution) line: 673
RemoteTestRunner.run() line: 386
RemoteTestRunner.main(String[]) line: 196
this is the configuration file for the entity:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="it.infocamere.ged.entity" >
<class name="Classifica" table="classifica" lazy="false">
<id name="guid" column="GUID" type="string"
access="field" length="30">
<generator class="assigned"/>
</id>
<version name="version" type="long" />
<property name="indice"
column="Indice"
type="string" />
<property name="pathCodice"
column="pathCodice"
type="string" />
<property name="denominazione"
column="Denominazione"
type="string" />
<property name="livello"
column="livello"
type="integer" />
<property name="abilitata"
column="abilitata"
type="boolean" />
<many-to-one name="titolario"
not-null="true"
column="id_titolario"
class="Titolario"
cascade="save-update" />
<many-to-one name="classifica_padre"
column="GUID_classifica_padre"
class="Classifica"
cascade="save-update" />
<set name="tipiFascicolo" table="tipoFascicolo_classifica" cascade="delete-orphan">
<key column="guid"/>
<many-to-many column="id_tipoFascicolo" class="it.infocamere.ged.entity.metainfo.TipoFascicolo"/>
</set>
</class>
</hibernate-mapping>
i've also noted a strange behaviour:
in a criteria query i use this entity, if i write:
c.add(Restrictions.eq(FascicoloImpl.FIELD_CLASSIFICA,criteriPerFascicolo.getClassifica()));
it's all right but if i try to write:
c.add(Restrictions.in(FascicoloImpl.FIELD_CLASSIFICA,ids));
or if i try to write:
Disjunction dis=Restrictions.disjunction();
for (String id:ids)
{
dis.add((Restrictions.eq(FascicoloImpl.FIELD_CLASSIFICA,id)));
}
c.add(dis);
i get this error, but in all cases the generated query is exactly as i expect.
any idea?
thanks in advance
aniello
|