Caused by: java.lang.RuntimeException: set oid on [com.imilia.server.domain.common.PhoneContact] arg[null] type[com.imilia.server.domain.common.PhoneContact] threw error at com.avaje.ebean.server.deploy.BeanProperty.setValue(BeanProperty.java:601) at com.avaje.ebean.server.deploy.BeanProperty.readSet(BeanProperty.java:459) ... 59 moreCaused by: java.lang.NullPointerException at com.imilia.server.domain.common.PhoneContact._ebean_setField(PhoneContact.java:1) at com.avaje.ebean.server.reflect.EnhanceBeanReflect$Setter.set(EnhanceBeanReflect.java:118) at com.avaje.ebean.server.deploy.BeanProperty.setValue(BeanProperty.java:592) ... 60 more
Firstly I changed the contact id to be a primitive int rather than an Integer (This only reproduces with primitive id properties).
public void test() { Customer c = new Customer(); c.setName("testll"); Ebean.save(c); Customer c1 = Ebean.find(Customer.class) .setAutofetch(false) .select("id") .join("contacts","id") .where().idEq(c.getId()) .findUnique(); List<Contact> contacts = c1.getContacts(); int sz = contacts.size(); Assert.assertTrue(sz == 0); }
More stack trace is:
javax.persistence.PersistenceException: Error readSet on com.imilia.server.domain.common.PhoneContact.oid at com.avaje.ebean.server.deploy.BeanProperty.readSet(BeanProperty.java:464) at com.avaje.ebean.server.deploy.id.IdBinderSimple.readSet(IdBinderSimple.java:109) at com.avaje.ebean.server.query.SqlTreeNodeBean.load(SqlTreeNodeBean.java:224) at com.avaje.ebean.server.query.SqlTreeNodeManyRoot.load(SqlTreeNodeManyRoot.java:30) at com.avaje.ebean.server.query.SqlTreeNodeBean.load(SqlTreeNodeBean.java:290) at com.avaje.ebean.server.query.CQuery.readRow(CQuery.java:557) at com.avaje.ebean.server.query.CQuery.readBeanInternal(CQuery.java:594) at com.avaje.ebean.server.query.CQuery.readTheRows(CQuery.java:675) at com.avaje.ebean.server.query.CQuery.readCollection(CQuery.java:660) at com.avaje.ebean.server.query.CQueryEngine.findMany(CQueryEngine.java:166) at com.avaje.ebean.server.query.DefaultOrmQueryEngine.findMany(DefaultOrmQueryEngine.java:88) at com.avaje.ebean.server.core.OrmQueryRequest.findList(OrmQueryRequest.java:277) at com.avaje.ebean.server.core.DefaultServer.findList(DefaultServer.java:1280) at com.avaje.ebean.server.core.DefaultBeanLoader.loadMany(DefaultBeanLoader.java:143) at com.avaje.ebean.server.core.DefaultServer.loadMany(DefaultServer.java:370) at com.avaje.ebean.server.loadcontext.DLoadManyContext.loadMany(DLoadManyContext.java:143) at com.avaje.ebean.common.AbstractBeanCollection.lazyLoadCollection(AbstractBeanCollection.java:140) at com.avaje.ebean.common.BeanSet.init(BeanSet.java:110) at com.avaje.ebean.common.BeanSet.iterator(BeanSet.java:234) at com.imilia.server.service.impl.AddressServiceImpl.save(AddressServiceImpl.java:34) at com.imilia.server.service.impl.AddressServiceImpl.save(AddressServiceImpl.java:21) 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:592) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy43.save(Unknown Source) at com.imilia.server.service.impl.PersonServiceImpl.save(PersonServiceImpl.java:29) at com.imilia.server.service.impl.PersonServiceImpl.save(PersonServiceImpl.java:19) 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:592) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198) at $Proxy44.save(Unknown Source) at com.imilia.bkf.service.impl.SubscriptionServiceImpl.saveSubscriptionPersonAddress(SubscriptionServiceImpl.java:51) 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:592) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy45.saveSubscriptionPersonAddress(Unknown Source) at com.imilia.bkf.service.SubscriptionServiceTest.testSaveSubscriptons(SubscriptionServiceTest.java:81) 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:592) at org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:160) at org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233) at org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333) at org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217) at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197) at org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:160) at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51) at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44) at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27) at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37) at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97) at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127) at org.apache.maven.surefire.Surefire.run(Surefire.java:177) 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:592) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)Caused by: java.lang.RuntimeException: set oid on [com.imilia.server.domain.common.PhoneContact] arg[null] type[com.imilia.server.domain.common.PhoneContact] threw error at com.avaje.ebean.server.deploy.BeanProperty.setValue(BeanProperty.java:601) at com.avaje.ebean.server.deploy.BeanProperty.readSet(BeanProperty.java:459) ... 80 moreCaused by: java.lang.NullPointerException at com.imilia.server.domain.common.PhoneContact._ebean_setField(PhoneContact.java:1) at com.avaje.ebean.server.reflect.EnhanceBeanReflect$Setter.set(EnhanceBeanReflect.java:118) at com.avaje.ebean.server.deploy.BeanProperty.setValue(BeanProperty.java:592) ... 81 more
testSaveAddress(com.imilia.bkf.service.SubscriptionServiceTest) Time elapsed: 0.008 sec <<< ERROR!javax.persistence.PersistenceException: Error readSet on com.imilia.server.domain.common.PhoneContact.oid at com.avaje.ebean.server.deploy.BeanProperty.readSet(BeanProperty.java:464) at com.avaje.ebean.server.deploy.id.IdBinderSimple.readSet(IdBinderSimple.java:109) at com.avaje.ebean.server.query.SqlTreeNodeBean.load(SqlTreeNodeBean.java:224) at com.avaje.ebean.server.query.SqlTreeNodeManyRoot.load(SqlTreeNodeManyRoot.java:30) at com.avaje.ebean.server.query.SqlTreeNodeBean.load(SqlTreeNodeBean.java:290) at com.avaje.ebean.server.query.CQuery.readRow(CQuery.java:557) at com.avaje.ebean.server.query.CQuery.readBeanInternal(CQuery.java:594) at com.avaje.ebean.server.query.CQuery.readTheRows(CQuery.java:675) at com.avaje.ebean.server.query.CQuery.readCollection(CQuery.java:660) at com.avaje.ebean.server.query.CQueryEngine.findMany(CQueryEngine.java:166) at com.avaje.ebean.server.query.DefaultOrmQueryEngine.findMany(DefaultOrmQueryEngine.java:88) at com.avaje.ebean.server.core.OrmQueryRequest.findList(OrmQueryRequest.java:277) at com.avaje.ebean.server.core.DefaultServer.findList(DefaultServer.java:1280) at com.avaje.ebean.server.core.DefaultBeanLoader.loadMany(DefaultBeanLoader.java:143) at com.avaje.ebean.server.core.DefaultServer.loadMany(DefaultServer.java:370) at com.avaje.ebean.server.loadcontext.DLoadManyContext.loadMany(DLoadManyContext.java:143) at com.avaje.ebean.common.AbstractBeanCollection.lazyLoadCollection(AbstractBeanCollection.java:140) at com.avaje.ebean.common.BeanSet.init(BeanSet.java:110) at com.avaje.ebean.common.BeanSet.iterator(BeanSet.java:234) at com.imilia.server.service.impl.AddressServiceImpl.save(AddressServiceImpl.java:34) at com.imilia.server.service.impl.AddressServiceImpl.save(AddressServiceImpl.java:21) 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:592) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy43.save(Unknown Source) at com.imilia.bkf.service.SubscriptionServiceTest.testSaveAddress(SubscriptionServiceTest.java:100) 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:592) at org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:160) at org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233) at org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333) at org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217) at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197) at org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:160) at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51) at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44) at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27) at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37) at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97) at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127) at org.apache.maven.surefire.Surefire.run(Surefire.java:177) 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:592) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)Caused by: java.lang.RuntimeException: set oid on [com.imilia.server.domain.common.PhoneContact] arg[null] type[com.imilia.server.domain.common.PhoneContact] threw error at com.avaje.ebean.server.deploy.BeanProperty.setValue(BeanProperty.java:601) at com.avaje.ebean.server.deploy.BeanProperty.readSet(BeanProperty.java:459) ... 59 moreCaused by: java.lang.NullPointerException at com.imilia.server.domain.common.PhoneContact._ebean_setField(PhoneContact.java:1) at com.avaje.ebean.server.reflect.EnhanceBeanReflect$Setter.set(EnhanceBeanReflect.java:118) at com.avaje.ebean.server.deploy.BeanProperty.setValue(BeanProperty.java:592) ... 60 more
The issue ... is specific to primitive id properties.
Specifically when we read from the resultSet we can always get a null (even for int and long etc). The fix is for IdBinders to specifically check for the case of trying to set null ids.
Fixed in HEAD.