I'm trying to create a Hibernate projection for database stored File and its versions like this:
Code:
DetachedCriteria criteria = DetachedCriteria.forClass(File.class, "file");
criteria.createAlias("versions","versions", CriteriaSpecification.LEFT_JOIN);
criteria.createAlias("publishedVersion","publishedVersion", CriteriaSpecification.LEFT_JOIN);
criteria.setProjection(
Projections.projectionList()
.add(Projections.alias(Projections.property("uuid"), "uuid"))
.add(Projections.alias(Projections.property("name"), "name"))
.add(Projections.alias(Projections.property("contentType"), "contentType"))
.add(Projections.alias(Projections.property("extension"), "extension"))
.add(Projections.alias(Projections.property("parent"), "parent"))
.add(Projections.alias(Projections.property("creationDate"), "creationDate"))
.add(Projections.alias(Projections.property("updateDate"), "updateDate"))
.add(Projections.alias(Projections.property("publishedVersion"), "publishedVersion"))
.add(Projections.alias(Projections.property("versions"), "versions"))
);
criteria.setResultTransformer(Transformers.aliasToBean(NodeView.class));
criteria.add((parent==null)?
Restrictions.isNull("parent"):
Restrictions.eq("parent", parent));
List records = hibernateTemplate.findByCriteria(criteria);
I'm trying to create a Hibernate projection for database stored File and its versions like this:
DetachedCriteria criteria = DetachedCriteria.forClass(File.class, "file");
criteria.createAlias("versions","versions", CriteriaSpecification.LEFT_JOIN);
criteria.createAlias("publishedVersion","publishedVersion", CriteriaSpecification.LEFT_JOIN);
criteria.setProjection(
Projections.projectionList()
.add(Projections.alias(Projections.property("uuid"), "uuid"))
.add(Projections.alias(Projections.property("name"), "name"))
.add(Projections.alias(Projections.property("contentType"), "contentType"))
.add(Projections.alias(Projections.property("extension"), "extension"))
.add(Projections.alias(Projections.property("parent"), "parent"))
.add(Projections.alias(Projections.property("creationDate"), "creationDate"))
.add(Projections.alias(Projections.property("updateDate"), "updateDate"))
.add(Projections.alias(Projections.property("publishedVersion"), "publishedVersion"))
.add(Projections.alias(Projections.property("versions"), "versions"))
);
criteria.setResultTransformer(Transformers.aliasToBean(NodeView.class));
criteria.add((parent==null)?
Restrictions.isNull("parent"):
Restrictions.eq("parent", parent));
List records = hibernateTemplate.findByCriteria(criteria);
I'm getting following error:
Code:
ERROR: com.objectverse.dms.web.fileexplorer.FileExplorerController - java.lang.ArrayIndexOutOfBoundsException: 8
23.8.2011 16:05:52 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [appServlet] in context with path [/com.objectverse] threw exception [Request processing failed; nested exception is org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only] with root cause
org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:717)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
at com.objectverse.dms.web.fileexplorer.FileExplorerController$$EnhancerByCGLIB$$44729f57_2.getSubNodes(<generated>)
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:597)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
The problem is in versions property that I need within the NodeView ResultTransformer. How can I get versions?
The error happens in
Code:
List records = hibernateTemplate.findByCriteria(criteria);
Any help appreciated.