Hibernate version: 2.1.6
Mapping documents:
<class name="it.ph.ddalbum.model.AlbumDirty" table="phdda_albums_dirty" >
<id name="id" type="int" column="aid" unsaved-value="0">
<generator class="assigned"/>
</id>
<property name="nome"/>
<property name="pubblico" type="boolean"/>
<property name="password"/>
<many-to-one name="utente" column="uid" class="it.ph.ddalbum.model.Utente" outer-join="true"/>
<many-to-one name="categoria" column="cid" class="it.ph.ddalbum.model.Categoria" outer-join="true"/>
</class>
<class name="it.ph.ddalbum.model.Album" table="phdda_albums" >
<id name="id" type="int" column="aid" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="nome"/>
<property name="pubblico" type="boolean"/>
<property name="dirty" type="boolean"/>
<property name="attivo" type="boolean"/>
<property name="password"/>
<property name="dataMod" column="data_mod"/>
<property name="dataIns" column="data_ins"/>
<bag name="fotografie" order-by="datains DESC" lazy="false" where="attiva='1' AND attiva_utente='1'">
<key column="aid"/>
<one-to-many class="it.ph.ddalbum.model.Foto"/>
</bag>
<many-to-one name="utente" column="uid" class="it.ph.ddalbum.model.Utente" outer-join="true"/>
<many-to-one name="categoria" column="cid" class="it.ph.ddalbum.model.Categoria" outer-join="true"/>
</class>
Code between sessionFactory.openSession() and session.close():
String s = "SELECT a FROM it.ph.ddalbum.model.Album as a ORDER BY a.dataIns";
String sc="SELECT count(*) FROM it.ph.ddalbum.model.Album as a";
response.setCount(((Integer) sess.iterate(sc).next()).intValue());
Query query = htmpl.createQuery(sess,s);
query.setFirstResult(offset);
query.setMaxResults(count);
response.setResponse(new Vector(query.list()));
Full stack trace of any exception that occurs:
net.sf.hibernate.QueryException: could not resolve property: dataIns of: it.ph.ddalbum.model.AlbumDirty [SELECT a FROM it.ph.ddalbum.model.AlbumDirty as a ORDER BY a.dataIns]
at net.sf.hibernate.persister.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:38)
at net.sf.hibernate.hql.PathExpressionParser.getPropertyType(PathExpressionParser.java:249)
at net.sf.hibernate.hql.PathExpressionParser.end(PathExpressionParser.java:288)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
at net.sf.hibernate.hql.OrderByParser.token(OrderByParser.java:30)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:142)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:294)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1562)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1533)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at it.ph.ddalbum.model.dao.AlbumDao.getAllPageable(AlbumDao.java:160)
at it.ph.ddalbum.struts.AlbumFeAdminAction.browse(AlbumFeAdminAction.java:180)
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 org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:276)
at it.ph.ddalbum.struts.AlbumFeAdminAction.dispatchMethod(AlbumFeAdminAction.java:55)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:196)
at org.apache.struts.actions.MappingDispatchAction.execute(MappingDispatchAction.java:171)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at bazu.utils.filters.LoginCheckFilter.doFilter(LoginCheckFilter.java:89)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:220)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.jboss.web.tomcat.tc4.statistics.ContainerStatsValve.invoke(ContainerStatsValve.java:76)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:65)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:197)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:605)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:677)
at java.lang.Thread.run(Thread.java:534)
Name and version of the database you are using:
Mysql 4
The generated SQL (show_sql=true):
Hibernate: select count(*) as x0_0_ from phdda_albums album0_
12:28:40,703 INFO [STDOUT] Hibernate: select count(*) as x0_0_ from phdda_albums_dirty albumdirty0_
12:28:41,609 ERROR [root] could not resolve property: dataIns of: it.ph.ddalbum.model.AlbumDirty [SELECT a FROM it.ph.ddalbum.model.AlbumDirty as a ORDER BY a.dataIns]
Debug level Hibernate log excerpt: INFO
My question i've mapped 2 classes AlbumDirty sublcass of Album as 2 separate classes into 2 separate tables. In AlbumDirty I've not mapped all attributes and so the Exception is clear BUT the query that I do is ON Album AND NOT in AlbumDirty. Every time that i do a query it run twice: one in AlbumDirty an one in Album... why??
|