Thanks Mike!
Another issue that seems to have appeared in the upgrade is that I get database warnings for change to the database before testing: [myapp] WARN [main] JDBCExceptionReporter.logWarnings(49) | 'TYPE=storage_e ngine' is deprecated; use 'ENGINE=storage_engine' instead [myapp] WARN [main] JDBCExceptionReporter.logWarnings(48) | SQL Warning: 12 87, SQLState: HY000 Thanks again Aled From: Michael Horwitz [mailto:[EMAIL PROTECTED] Sent: 22 October 2007 21:51 To: [email protected] Subject: Re: [appfuse-user] FW: Hibernate issues after upgrading to appfuse 2.0 On 10/22/07, Aled Rhys Jones <[EMAIL PROTECTED]> wrote: Any ideas regarding the below guys? Thanks Aled From: Aled Rhys Jones [mailto:[EMAIL PROTECTED] Sent: 20 October 2007 16:31 To: '[email protected]' Subject: Hibernate issues after upgrading to appfuse 2.0 Hi all I've just updated from a m4 of appfuse 2.0 to the release version. I'm having a few teething issues with this new version. Now all my DAOTests fail on my add and remove tests. I've debugged the code, and when the model is saved after creation, the id is not updated, so the get function fails as follows: ---------------------------------------------------------------------------- --- Test set: .....dao.AssociationDAOTest ---------------------------------------------------------------------------- --- Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.377 sec <<< FAILURE! testAddAndRemoveAssociation(......dao.AssociationDAOTest) Time elapsed: 0.372 sec <<< ERROR! java.lang.IllegalArgumentException: id to load is required for loading at org.hibernate.event.LoadEvent.<init>(LoadEvent.java:51) at org.hibernate.event.LoadEvent.<init>(LoadEvent.java:33) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:812) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808) at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(Hiberna teTemplate.java:470) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTempla te.java:372) at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.j ava:464) at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.j ava:458) at org.appfuse.dao.hibernate.GenericDaoHibernate.get(GenericDaoHibernate.java:5 7) at ........dao.AssociationDAOTest.testAddAndRemoveAssociation(AssociationDAOTes t.java:41) 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 junit.framework.TestCase.runTest(TestCase.java:168) at junit.framework.TestCase.runBare(TestCase.java:134) at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.jav a:69) 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.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62 ) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(Ab stractDirectoryTestSuite.java:138) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractD irectoryTestSuite.java:125) at org.apache.maven.surefire.Surefire.run(Surefire.java:132) 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.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireB ooter.java:290) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818 ) As of 2.0M5 the save() operation on the GenericDaoHibernate was changed from saveOrUpdate() to merge() to prevent errors being thrown if the object is in the session. The side effect is that only the object returned by the save() method is made persistent (the return object is also a new feature). You must use the object returned from the save methods in your tests (and make sure your Dao's also return objects from any method extending save()). If I disable those tests, my application loads ok and more or less works, but I know have an issue where it can't load a collection of models associated with a model in one of my forms: [travelbeen] ERROR [btpool0-5] LazyInitializationException.<init>(19) | failed t o lazily initialize a collection of role: ..........model.Website.w ebsiteAssociations, no session or session was closed org.hibernate.LazyInitializationException: failed to lazily initialize a collect ion of role: .........model.Website.websiteAssociations, no sessio n or session was closed at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitia lizationException(AbstractPersistentCollection.java:358) at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitia lizationExceptionIfNotConnected(AbstractPersistentCollection.java:350) at org.hibernate.collection.AbstractPersistentCollection.readSize(Abstra ctPersistentCollection.java:97) at org.hibernate.collection.PersistentBag.size(PersistentBag.java:225) at org.displaytag.tags.TableTag.initParameters(TableTag.java:1003) at org.displaytag.tags.TableTag.doStartTag(TableTag.java:722) at org.apache.jsp.WEB_002dINF.pages.websiteform_jsp._jspx_meth_display_t able_0(org.apache.jsp.WEB_002dINF.pages.websiteform_jsp:2206) The OpenSessionInView filter in web.xml, along with its filter mapping, is now commented out by default to be friendly to the iBatis people. You need to uncomment these two to prevent the error you are seeing above. Mike. Any ideas? Thanks in advance Aled
