persistence@glassfish.java.net

Code Review for Validation related change in entity-persistence

From: Sanjeeb Kumar Sahoo <Sanjeeb.Sahoo_at_Sun.COM>
Date: Thu, 10 Nov 2005 20:08:43 +0530

Hi Peter,
 Thanks for your suggestion. Please see my comments in line..
Peter Krogh wrote:

>This is further to our discussion on validation. Again, sceduling time to this task above other tasks doesn't make sense for me at this time. We discussed that it would be better for Sun to verify that the following approach suits your needs.
>
>I have looked into this briefly and I believe that the best approach is to call a method on a TopLink session called initializeDescriptors().
>
>So the code path should be something like this:
>Currently oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerFactoryImpl getEntityManager() calls
> serverSession.login()
>
>
>
EntityManagerFactoryImpl.getEntityManager() is not called in the
validation call stack. The validation code just creates an EMF by
calling
EntityManagerFactoryProvider.createContainerEntityManagerFactory(PersistenceUnitInfo).

I have modified EntityManagerFactoryProvider to just call
initializeDescriptors() in validation mode. Please see the attached code.

>a property check needs to be added to call
>
>serverSession.initializeDescriptors() if validation is on
>

>Note
> you must check to make sure that this non logged in EntityManager gets thrown away properly, and no references to it exist anymore.
>
>
>
We don't create any EntityManager as it is not required for validation.
At the end of validation, verifier calls EntityManagerFactory.close().

>When this solution is verified and meets yours needs, we will review it.
>
>
>
Attached here with is the change as well as the original file. Please
let me know your comments.

I have also modified our verifier to use the new property. With these
changes, I did some unit testing using our verifier. I tested both a
positive (positive means the persistence jar was written to spec) and a
negative (persistence jar had some issues) case.
For the negative case, createEMF reported IntegrityException or
ValidationException.
For the positive case, createEMF did not report any exceptions. In the
past createEMF() used to throw a DatabaseException while trying to login
using the default connector.

When verifier called EMF.close(), I saw a message like this:
[TopLink Info]: 2005.11.10 07:37:35.804--ServerSession(25374911)--em1
logout successful

Since it is not actually throwing any exception during logout, do you
think we have to propagate the validationMode to EntityManagerFactoryImpl?

Finally, in y'day's meeting Gordon mentioned about throwing a validation
exception if data-source is null. When that code gets introduced, that
should not throw exception in validationMode.

Look forward to your comments.

Thanks & regards,
Sahoo

>Thanks
>
>