Bug 132 : ClassCastException ... java.lang.RuntimeException: set details on ... when join to many that is not on root
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
2.0.2
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
01/08/2009
Updated 
01/08/2009
Type 
Bug
 
Attachments 
No attachments

java.lang.RuntimeException: set details on [com.avaje.tests.model.basic.Order] arg[BeanList size[0] hasMoreRows[false] list[]] type[com.avaje.tests.model.basic.OrderShipment] threw error
at com.avaje.ebean.server.deploy.BeanProperty.setValue(BeanProperty.java:582)
at com.avaje.ebean.server.query.CQuery.createNewDetailCollection(CQuery.java:520)
at com.avaje.ebean.server.query.CQuery.readBeanInternal(CQuery.java:487)
at com.avaje.ebean.server.query.CQuery.readTheRows(CQuery.java:559)
at com.avaje.ebean.server.query.CQuery.readCollection(CQuery.java:543)
at com.avaje.ebean.server.query.CQueryEngine.findMany(CQueryEngine.java:112)
at com.avaje.ebean.server.query.DefaultOrmQueryEngine.findMany(DefaultOrmQueryEngine.java:98)
at com.avaje.ebean.server.core.OrmQueryRequest.findList(OrmQueryRequest.java:228)
at com.avaje.ebean.server.core.DefaultServer.findList(DefaultServer.java:1054)
at com.avaje.ebean.server.querydefn.DefaultOrmQuery.findList(DefaultOrmQuery.java:557)
at com.avaje.tests.query.TestJoinQuery.test(TestJoinQuery.java:35)
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:585)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassCastException: com.avaje.tests.model.basic.OrderShipment
at com.avaje.tests.model.basic.Order._ebean_setField(Order.java:1)
at com.avaje.ebean.server.reflect.EnhanceBeanReflect$Setter.set(EnhanceBeanReflect.java:118)
at com.avaje.ebean.server.deploy.BeanProperty.setValue(BeanProperty.java:573)
... 29 more

 
Rob 01 Aug 02:33
The issue here...

The issue here is that when you fetch join to a "Many" ... it needs to be at the root level, otherwise you get an exception like this.

There is the assumption that the Many is at the root level and that assumption was removed from the SqlTreeBuilder ... but still on the CQuery so the many "Set/List/Map" was not being set correctly - hence the error.

Rob 01 Aug 02:49
Autofetch

With Autofetch on this could lead to extra joins like this (so you could get this when you turn on autofetch and conversely it could go away if you turn off autofetch).

Fixed in HEAD.

woResponse

Upload a file