Hi Mitesh,
To try and make a simple example is a bit difficult, since this is a large application that previously used to run fine on Glassfish V2 with TopLink. I have ported the application to Glassfish V3 (not simply just running the unmodified app), but by using all the good new stuff in EJB 3.1. My entity classes, however, have remained the same (because the database is the same). The general packaging of the application has remained the same. Restarting, redeploying, and any combination of such, yields the same results.
The entity classes are packaged in one EJB module, while the persistence.xml file is packaged with the data access beans in another EJB module. The persistence.xml file references the EJB where the data entities are found. I don't know if this could possibly a clue to the problem. Here is the contents of the persistence.xml file :-
<persistence-unit name="Test" transaction-type="JTA">
<jta-data-source>jdbc/__Test</jta-data-source>
<jar-file>TestDataEntities.jar</jar-file>
<properties/>
</persistence-unit>
From the Glassfish log, it would appear that the entity classes should be accessible to the weaver, since it is full of "xxxxx actually got transformed" messages, where the xxxx is the name of an entity class.
Amongst the entities are a few that have one-to-one relationships with others. The @OneToOne annotation is on the accessor methods (not the fields). Everything works fine if just the @OneToOne annotation is used - the application deploys 100%, and works 100%. But I don't want the eager fetching associated with @OneToOne, but if you put in @OneToOne(fetch = FetchType.LAZY) on even just one of these instances, the exception occurs in the application the moment the parent entity is referenced.
My feelings here is that this used to be a long-time problem in TopLink, which somewhere along the line got fixed (I'm not sure exactly when, because for a long time I didn't have the fetch = LAZY in the entities for the TopLink version, but one day I tried it, and it worked fine). So then I tried the same with the version for EclipseLink, and found that fetch = LAZY doesn't work - hence the reason for this post.
Regards,
Steve.
[Message sent by forum member 'suttridge_farm' (steve_at_vanrhynsdorp.co.za)]
http://forums.java.net/jive/thread.jspa?messageID=389961