Thread:
 Identity test fails? 
 greyfairer   01 Aug 2005, 08:21 

Comment
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
From: greyfairer (01 Aug 2005, 08:21) Replies: 0, Views: 37179
Subject: Identity test fails?
I wrote similar code, but found weird behaviour when running JUnit tests 
on it.  I posted a question on the user forum, http://forum.hibernate.
org/viewtopic.php?t=945748.

Basically,backporting to your code:
 
Democrat proxy = session.load(Democrat.class, id);
Democrat visited = new PoliticianViewHelper(proxy).getDemocrat();
assertNotNull(visited); //ok
assertEquals(id, visited.id); //ok
assertSame(proxy, visited; //FAILS

It turns out that in the invocation of the accept() method, the 'this' 
pointer does not point to the proxy instance, but to a real instance of 
the Democrat class.

The Visitor pattern as you described is still very valuable, off course, 
but this one surprised me.
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
© Copyright 2006, Red Hat Middleware, LLC. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc. [Privacy Policy]