Anybody can help me with this log?
I have a class UnidadADministrativa that holds a collection of unidadAdministrativa, and a parent(its a composite pattern).
First i load an object (parent) and then i find the objects that has it as it parent, and i have an error i don't understand.
Code:
17:31:02,296 DEBUG DefaultLoadEventListener:169 - loading entity: [com.dominio.unidades.UnidadAdministrativa#46]
17:31:02,296 DEBUG DefaultLoadEventListener:328 - attempting to resolve: [com.dominio.unidades.UnidadAdministrativa#46]
17:31:02,296 DEBUG DefaultLoadEventListener:368 - object not resolved in any cache: [com.dominio.unidades.UnidadAdministrativa#46]
17:31:02,296 DEBUG AbstractEntityPersister:2970 - Fetching entity: [com.dominio.unidades.UnidadAdministrativa#46]
17:31:02,296 DEBUG Loader:1776 - loading entity: [com.dominio.unidades.UnidadAdministrativa#46]
17:31:02,296 DEBUG AbstractBatcher:358 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
17:31:02,296 DEBUG SQL:393 - select unidadadmi0_.id as id0_0_, unidadadmi0_2_.padre_id as padre2_0_0_, unidadadmi0_.activada as activada2_0_, unidadadmi0_.nombre as nombre2_0_ from UnidadAdministrativa unidadadmi0_ inner join UnidadCompuesto unidadadmi0_1_ on unidadadmi0_.id=unidadadmi0_1_.id inner join Unidad unidadadmi0_2_ on unidadadmi0_.id=unidadadmi0_2_.id where unidadadmi0_.id=?
Hibernate: select unidadadmi0_.id as id0_0_, unidadadmi0_2_.padre_id as padre2_0_0_, unidadadmi0_.activada as activada2_0_, unidadadmi0_.nombre as nombre2_0_ from UnidadAdministrativa unidadadmi0_ inner join UnidadCompuesto unidadadmi0_1_ on unidadadmi0_.id=unidadadmi0_1_.id inner join Unidad unidadadmi0_2_ on unidadadmi0_.id=unidadadmi0_2_.id where unidadadmi0_.id=?
17:31:02,296 DEBUG AbstractBatcher:476 - preparing statement
17:31:02,296 DEBUG AbstractBatcher:374 - about to open ResultSet (open ResultSets: 0, globally: 0)
17:31:02,296 DEBUG Loader:682 - processing result set
17:31:02,296 DEBUG Loader:687 - result set row: 0
17:31:02,296 DEBUG Loader:1164 - result row: EntityKey[com.dominio.unidades.UnidadAdministrativa#46]
17:31:02,312 DEBUG Loader:1346 - Initializing object from ResultSet: [com.dominio.unidades.UnidadAdministrativa#46]
17:31:02,312 DEBUG AbstractEntityPersister:1966 - Hydrating entity: [com.dominio.unidades.UnidadAdministrativa#46]
17:31:02,312 DEBUG Loader:709 - done processing result set (1 rows)
17:31:02,312 DEBUG AbstractBatcher:381 - about to close ResultSet (open ResultSets: 1, globally: 1)
17:31:02,312 DEBUG AbstractBatcher:366 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
17:31:02,312 DEBUG AbstractBatcher:525 - closing statement
17:31:02,312 DEBUG Loader:839 - total objects hydrated: 1
17:31:02,312 DEBUG TwoPhaseLoad:107 - resolving associations for [com.dominio.unidades.UnidadAdministrativa#46]
17:31:02,312 DEBUG DefaultLoadEventListener:169 - loading entity: [com.dominio.unidades.Unidad#48]
17:31:02,312 DEBUG DefaultLoadEventListener:253 - creating new proxy for entity
17:31:02,328 DEBUG CollectionLoadContext:141 - creating collection wrapper:[com.dominio.unidades.UnidadCompuesto.unidades#46]
17:31:02,328 DEBUG TwoPhaseLoad:206 - done materializing entity [com.dominio.unidades.UnidadAdministrativa#46]
17:31:02,328 DEBUG StatefulPersistenceContext:748 - initializing non-lazy collections
17:31:02,328 DEBUG Loader:1807 - done entity load
17:31:02,328 DEBUG QueryPlanCache:70 - unable to locate HQL query plan in cache; generating (SELECT unidad FROM Unidad unidad WHERE unidad.padre = :unidad)
17:31:02,328 DEBUG QueryTranslatorImpl:246 - parse() - HQL: SELECT unidad FROM com.dominio.unidades.Unidad unidad WHERE unidad.padre = :unidad
17:31:02,328 DEBUG AST:266 - --- HQL AST ---
\-[QUERY] 'query'
+-[SELECT_FROM] 'SELECT_FROM'
| +-[FROM] 'FROM'
| | \-[RANGE] 'RANGE'
| | +-[DOT] '.'
| | | +-[DOT] '.'
| | | | +-[DOT] '.'
| | | | | +-[IDENT] 'com'
| | | | | \-[IDENT] 'dominio'
| | | | \-[IDENT] 'unidades'
| | | \-[IDENT] 'Unidad'
| | \-[ALIAS] 'unidad'
| \-[SELECT] 'SELECT'
| \-[IDENT] 'unidad'
\-[WHERE] 'WHERE'
\-[EQ] '='
+-[DOT] '.'
| +-[IDENT] 'unidad'
| \-[IDENT] 'padre'
\-[COLON] ':'
\-[IDENT] 'unidad'
17:31:02,328 DEBUG ErrorCounter:68 - throwQueryException() : no errors
17:31:02,328 DEBUG HqlSqlBaseWalker:111 - select << begin [level=1, statement=select]
17:31:02,343 DEBUG FromElement:105 - FromClause{level=1} : com.dominio.unidades.Unidad (unidad) -> unidad0_
17:31:02,343 DEBUG FromReferenceNode:51 - Resolved : unidad -> unidad0_.id
17:31:02,343 DEBUG FromReferenceNode:51 - Resolved : unidad -> unidad0_.id
17:31:02,343 DEBUG DotNode:541 - getDataType() : padre -> org.hibernate.type.ManyToOneType(com.dominio.unidades.Unidad)
17:31:02,343 DEBUG DotNode:497 - dereferenceShortcut() : property padre in com.dominio.unidades.Unidad does not require a join.
17:31:02,343 DEBUG FromReferenceNode:51 - Resolved : unidad.padre -> unidad0_.padre_id
17:31:02,343 DEBUG HqlSqlBaseWalker:117 - select : finishing up [level=1, statement=select]
17:31:02,343 DEBUG HqlSqlWalker:516 - processQuery() : ( SELECT ( {select clause} unidad0_.id ) ( FromClause{level=1} Unidad unidad0_ ) ( WHERE ( = ( unidad0_.padre_id unidad0_.id padre ) ? ) ) )
17:31:02,359 DEBUG JoinProcessor:129 - Using FROM fragment [Unidad unidad0_ left outer join UnidadCompuesto unidad0_1_ on unidad0_.id=unidad0_1_.id left outer join UnidadAdministrativa unidad0_2_ on unidad0_.id=unidad0_2_.id]
17:31:02,359 DEBUG HqlSqlBaseWalker:123 - select >> end [level=1, statement=select]
17:31:02,359 DEBUG AST:232 - --- SQL AST ---
\-[SELECT] QueryNode: 'SELECT' querySpaces (Unidad)
+-[SELECT_CLAUSE] SelectClause: '{select clause}'
| +-[ALIAS_REF] IdentNode: 'unidad0_.id as id0_' {alias=unidad, className=com.dominio.unidades.Unidad, tableAlias=unidad0_}
| \-[SQL_TOKEN] SqlFragment: 'unidad0_.padre_id as padre2_0_, unidad0_2_.activada as activada2_, unidad0_2_.nombre as nombre2_, case when unidad0_2_.id is not null then 2 when unidad0_1_.id is not null then 1 when unidad0_.id is not null then 0 end as clazz_'
+-[FROM] FromClause: 'FROM' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[unidad], fromElementByTableAlias=[unidad0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
| \-[FROM_FRAGMENT] FromElement: 'Unidad unidad0_ left outer join UnidadCompuesto unidad0_1_ on unidad0_.id=unidad0_1_.id left outer join UnidadAdministrativa unidad0_2_ on unidad0_.id=unidad0_2_.id' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=unidad,role=null,tableName=Unidad,tableAlias=unidad0_,origin=null,colums={,className=com.dominio.unidades.Unidad}}
\-[WHERE] SqlNode: 'WHERE'
\-[EQ] BinaryLogicOperatorNode: '='
+-[DOT] DotNode: 'unidad0_.padre_id' {propertyName=padre,dereferenceType=ROOT_LEVEL,propertyPath=padre,path=unidad.padre,tableAlias=unidad0_,className=com.dominio.unidades.Unidad,classAlias=unidad}
| +-[ALIAS_REF] IdentNode: 'unidad0_.id' {alias=unidad, className=com.dominio.unidades.Unidad, tableAlias=unidad0_}
| \-[IDENT] IdentNode: 'padre' {originalText=padre}
\-[NAMED_PARAM] ParameterNode: '?' {name=unidad, expectedType=org.hibernate.type.ManyToOneType(com.dominio.unidades.Unidad)}
17:31:02,359 DEBUG ErrorCounter:68 - throwQueryException() : no errors
17:31:02,359 DEBUG QueryTranslatorImpl:216 - HQL: SELECT unidad FROM com.dominio.unidades.Unidad unidad WHERE unidad.padre = :unidad
17:31:02,359 DEBUG QueryTranslatorImpl:217 - SQL: select unidad0_.id as id0_, unidad0_.padre_id as padre2_0_, unidad0_2_.activada as activada2_, unidad0_2_.nombre as nombre2_, case when unidad0_2_.id is not null then 2 when unidad0_1_.id is not null then 1 when unidad0_.id is not null then 0 end as clazz_ from Unidad unidad0_ left outer join UnidadCompuesto unidad0_1_ on unidad0_.id=unidad0_1_.id left outer join UnidadAdministrativa unidad0_2_ on unidad0_.id=unidad0_2_.id where unidad0_.padre_id=?
17:31:02,359 DEBUG ErrorCounter:68 - throwQueryException() : no errors
17:31:02,359 DEBUG HQLQueryPlan:269 - HQL param location recognition took 0 mills (SELECT unidad FROM Unidad unidad WHERE unidad.padre = :unidad)
17:31:02,375 DEBUG QueryPlanCache:76 - located HQL query plan in cache (SELECT unidad FROM Unidad unidad WHERE unidad.padre = :unidad)
17:31:02,375 DEBUG AbstractFlushingEventListener:58 - flushing session
17:31:02,375 DEBUG AbstractFlushingEventListener:111 - processing flush-time cascades
17:31:02,375 DEBUG Cascade:115 - processing cascade ACTION_PERSIST_ON_FLUSH for: com.dominio.unidades.UnidadAdministrativa
17:31:02,375 DEBUG AbstractEntityManagerImpl:417 - mark transaction for rollback
17:31:02,375 DEBUG JDBCTransaction:152 - rollback
17:31:02,375 DEBUG JDBCTransaction:193 - re-enabling autocommit
17:31:02,375 DEBUG JDBCTransaction:163 - rolled back JDBC Connection
17:31:02,375 DEBUG JDBCContext:215 - after transaction completion
17:31:02,375 DEBUG ConnectionManager:398 - aggressively releasing JDBC connection
17:31:02,375 DEBUG ConnectionManager:435 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
17:31:02,375 DEBUG SessionImpl:422 - after transaction completion
17:31:02,390 DEBUG SessionImpl:273 - closing session
17:31:02,390 DEBUG ConnectionManager:369 - connection already null in cleanup : no action
17:31:02,390 ERROR [spring]:253 - Servlet.service() para servlet spring lanzó excepción
javax.persistence.PersistenceException: org.hibernate.HibernateException: instance not of expected entity type: com.dominio.unidades.Unidad$$EnhancerByCGLIB$$5076c808 is not a: com.dominio.unidades.Unidad
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:641)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:73)
at com.dao.JpaUnidadDao.findHijos(JpaUnidadDao.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:203)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:162)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:78)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:209)
at $Proxy16.findHijos(Unknown Source)
at com.servicios.ServicioUnidadImp.obtenerHijos(ServicioUnidadImp.java:102)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:203)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:162)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:209)
at $Proxy18.obtenerHijos(Unknown Source)
at com.web.UnidadAdministrativaController.onSubmit(UnidadAdministrativaController.java:104)
at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:258)
at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:250)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:806)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:736)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:396)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:360)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.HibernateException: instance not of expected entity type: com.dominio.unidades.Unidad$$EnhancerByCGLIB$$5076c808 is not a: com.dominio.unidades.Unidad
at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassEntityPersister(AbstractEntityPersister.java:3568)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1347)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:180)
at org.hibernate.engine.CascadingAction$9.noCascade(CascadingAction.java:347)
at org.hibernate.engine.Cascade.cascade(Cascade.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:130)
at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:121)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1114)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:64)
... 49 more
17:31:15,812 INFO SessionFactoryImpl:767 - closing
Code:
this is the service i call with parameter id=46
public List<UnidadAdministrativa> obtenerHijos(long id) throws NoEncontradoException {
UnidadAdministrativa unidadPadre = unidadDao.findById(id);
if (unidadPadre == null)
throw new NoEncontradoException("No se encontro la unidad con id:" + id);
List<UnidadAdministrativa> hijos = unidadDao.findHijos(unidadPadre);
return hijos;
}
and this is the dao:
public List<UnidadAdministrativa> findHijos(UnidadAdministrativa unidad) {
Query query = em.createQuery("SELECT unidad FROM Unidad unidad WHERE unidad.padre = :unidad");
query.setParameter("unidad",unidad);
return query.getResultList();
}
Any idea...