EntityManagerFactoryImpl factory = null;
try {
factory = new EntityManagerFactoryImpl(emSetupImpl, properties);
emSetupImpl.setRequiresConnection(requiresConnection);
emSetupImpl.preInitializeCanonicalMetamodel(factory);
// This code has been added to allow validation to occur without actually calling createEntityManager
if (emSetupImpl.shouldGetSessionOnCreateFactory(properties)) {
factory.getDatabaseSession();
}