Thanks for the confirmation, I was worried about my sanity for a little while ;)

It'd be great if T5.4 came with Hibernate 4 out of the box.  In the meanwhile 
the approach you're suggesting (building our own and putting it into our local 
repo) works fine.

Cheers!
J

On Mar 22, 2012, at 6:53 PM, Kalle Korhonen wrote:

> On Thu, Mar 22, 2012 at 11:23 AM, Jochen Frey <[email protected]> wrote:
>> Hey Kalle, thanks for the quick response.
>> I think I found the reason why it's not working for me (and I am surprised 
>> what you're describing could have worked for you at all).  By way of a unit 
>> test I tried your approach (adding the <dependency> for Hibernate 4.1.1), 
>> and for me it fails with a
>>        Caused by: java.lang.NoSuchMethodError: 
>> org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
>> Since then I have found the reason for that, which this that 
>> SessionFactory.openSession() in:
>> - Hibernate 4.1 returns org.hibernate.Session
>> - Hibernate 3.6 returns org.hibernate.classic.Session.
> 
> I see, yes you are quite right. It only worked for because the tests I
> was running (with Mockito) had:
>               session = sessionFactory.openSession();
>               HibernateSessionSource sessionSource = 
> mock(HibernateSessionSource.class);
>               when(sessionSource.create()).thenReturn(session);
> 
> so not a very good test for this particular case.. but I wrongly
> assumed that tapestry-hibernate was using old APIs which is not the
> case (org.hibernate.Session is available in 3.x hibernate and
> tapestry-hibernate doesn't refer to the classic version) so just
> recompiling against the newer version is enough.
> 
>> Am I missing something?  Should this work without a recompile?
>> PS: Because (according to my experiments) it requires re-building the 
>> Tapestry binary, I assumed the 'dev' list was the right place ...
> 
> It's the right place. I don't see a problem upgrading T5.4.x snapshots
> to use Hibernate 4.1.x. At least that would save you from having to
> fork tapestry-hibernate, and you could just freeze the
> tapestry-hibernate version you are using (manually uploading
> tapestry-hibernate 5.4-<mycompany>-1 or some such version to your
> company repo).
> 
> Kalle
> 
> 
>> On Mar 21, 2012, at 11:23 PM, Kalle Korhonen wrote:
>> 
>>> Just as a test I ran tynamo's tapestry-hibernate-seedentity against
>>> 4.1.1 and after fixing the api changes (the metadata api has some
>>> changes that are potentially a problem to tapestry integration) it
>>> worked out fine. I'm using tapestry-hibernate 5.3.2. I only added the
>>> following to the pom:
>>>               <dependency>
>>>                       <groupId>org.hibernate</groupId>
>>>                       <artifactId>hibernate-core</artifactId>
>>>                       <version>4.1.1.Final</version>
>>>               </dependency>
>>> 
>>>> 1)  Is there something obviously wrong with this approach (I haven't been 
>>>> hacking at TS proper that much), and
>>> 
>>> Nothing that wrong except it seems not to be necessary.
>>> 
>>>> 2) Is there an easier way (e.g. removing the "transitive: false" and 
>>>> hoping for the best)?
>>> 
>>> Dependencies are yours to manage, even if the tools may help with
>>> them. In other words, take transitive dependencies only as the tool's
>>> initial guess of what you might need and verify what and which version
>>> you need yourself.
>>> 
>>> Kalle
>>> 
>> 
>> public class SaveEntityTest extends TapestryTestCase {
>> 
>>    HibernateSessionManager manager;
>>    PageTester pageTester;
>> 
>>    public SaveEntityTest() {
>>        pageTester = new PageTester("com.example.newapp", "newapp");
>>    }
>> 
>>    @Test
>>    public void simpleTest()
>>    {
>>        manager = 
>> pageTester.getRegistry().getService(HibernateSessionManager.class);
>>        manager.getSession().createQuery("delete Game").executeUpdate();
>>        manager.commit();
>> 
>>        Game game = new Game();
>>        game.setName("test");
>>        manager.getSession().save(game);
>>        manager.commit();
>>    }
>> }
>> 
>> [ERROR] ioc.Registry Error invoking method public static 
>> org.apache.tapestry5.hibernate.HibernateSessionManager 
>> org.apache.tapestry5.hibernate.HibernateCoreModule.buildHibernateSessionManager(org.apache.tapestry5.hibernate.HibernateSessionSource,org.apache.tapestry5.ioc.services.PerthreadManager):
>>  org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
>> [ERROR] ioc.Registry Operations trace:
>> [ERROR] ioc.Registry [ 1] Instantiating service HibernateSessionManager 
>> implementation via 
>> org.apache.tapestry5.hibernate.HibernateCoreModule.buildHibernateSessionManager(HibernateSessionSource,
>>  PerthreadManager) (at HibernateCoreModule.java:96)
>> [ERROR] ioc.Registry [ 2] Constructing service implementation via 
>> org.apache.tapestry5.hibernate.HibernateCoreModule.buildHibernateSessionManager(HibernateSessionSource,
>>  PerthreadManager) (at HibernateCoreModule.java:96)
>> org.apache.tapestry5.ioc.internal.OperationException: Error invoking method 
>> public static org.apache.tapestry5.hibernate.HibernateSessionManager 
>> org.apache.tapestry5.hibernate.HibernateCoreModule.buildHibernateSessionManager(org.apache.tapestry5.hibernate.HibernateSessionSource,org.apache.tapestry5.ioc.services.PerthreadManager):
>>  org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
>>        at 
>> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.logAndRethrow(OperationTrackerImpl.java:121)
>>        at 
>> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:88)
>>        at 
>> org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
>>        at 
>> org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1121)
>>        at 
>> org.apache.tapestry5.ioc.internal.util.ConstructionPlan.createObject(ConstructionPlan.java:60)
>>        at 
>> org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvoker.createObject(ServiceBuilderMethodInvoker.java:60)
>>        at 
>> org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator$1.invoke(OperationTrackingObjectCreator.java:45)
>>        at 
>> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
>>        at 
>> org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
>>        at 
>> org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1121)
>>        at 
>> org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator.createObject(OperationTrackingObjectCreator.java:49)
>>        at 
>> org.apache.tapestry5.ioc.internal.services.PerThreadServiceCreator.createObject(PerThreadServiceCreator.java:47)
>>        at $HibernateSessionManager_127dc602c6524ef5.delegate(Unknown Source)
>>        at $HibernateSessionManager_127dc602c6524ef5.getSession(Unknown 
>> Source)
>>        at $HibernateSessionManager_127dc602c6524ef4.getSession(Unknown 
>> Source)
>>        at 
>> com.example.newapp.entities.SaveEntityTest.simpleTest(SaveEntityTest.java:31)
>>        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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
>>        at org.testng.internal.Invoker.invokeMethod(Invoker.java:691)
>>        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:883)
>>        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1208)
>>        at 
>> org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
>>        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
>>        at org.testng.TestRunner.privateRun(TestRunner.java:758)
>>        at org.testng.TestRunner.run(TestRunner.java:613)
>>        at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
>>        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
>>        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
>>        at org.testng.SuiteRunner.run(SuiteRunner.java:240)
>>        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
>>        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)
>>        at org.testng.TestNG.runSuitesSequentially(TestNG.java:1137)
>>        at org.testng.TestNG.runSuitesLocally(TestNG.java:1062)
>>        at org.testng.TestNG.run(TestNG.java:974)
>>        at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:109)
>>        at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
>>        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)
>>        at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:106)
>> Caused by: java.lang.RuntimeException: Error invoking method public static 
>> org.apache.tapestry5.hibernate.HibernateSessionManager 
>> org.apache.tapestry5.hibernate.HibernateCoreModule.buildHibernateSessionManager(org.apache.tapestry5.hibernate.HibernateSessionSource,org.apache.tapestry5.ioc.services.PerthreadManager):
>>  org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
>>        at 
>> org.apache.tapestry5.ioc.internal.util.MethodInvoker.invoke(MethodInvoker.java:61)
>>        at 
>> org.apache.tapestry5.ioc.internal.util.LoggingInvokableWrapper.invoke(LoggingInvokableWrapper.java:42)
>>        at 
>> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
>>        ... 39 more
>> Caused by: java.lang.NoSuchMethodError: 
>> org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session;
>>        at 
>> org.apache.tapestry5.internal.hibernate.HibernateSessionSourceImpl.create(HibernateSessionSourceImpl.java:69)
>>        at $HibernateSessionSource_127dc602c6524ef2.create(Unknown Source)
>>        at 
>> org.apache.tapestry5.internal.hibernate.HibernateSessionManagerImpl.<init>(HibernateSessionManagerImpl.java:31)
>>        at 
>> org.apache.tapestry5.hibernate.HibernateCoreModule.buildHibernateSessionManager(HibernateCoreModule.java:96)
>>        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.tapestry5.ioc.internal.util.MethodInvoker.invoke(MethodInvoker.java:50)
>>        ... 41 more
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 

---
  [email protected]
  +1.415.366.0450
  @jochen_frey

Reply via email to