| Summary: | JPA: validation-only=True breaks EntityManager deploy because initializeDescriptors() is called before loginAndDetectDatasource() in login() causing a default to the generic DatabasePlatform superclass | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Michael OBrien <michael.f.obrien> |
| Component: | Eclipselink | Assignee: | Michael OBrien <michael.f.obrien> |
| Status: | RESOLVED WONTFIX | QA Contact: | |
| Severity: | major | ||
| Priority: | P2 | CC: | eclipselink.orm-inbox |
| Version: | unspecified | Flags: | michael.f.obrien:
documentation+
|
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| URL: | http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api#DI_106:_20100810:_322585:Metamodel_initialization_via_EMF.getMetamodel.28.29_before_EM_deploy_results_in_an_invalid_Metamodel_because_of_UNINITIALIZED_descriptor.initializationStage | ||
| Whiteboard: | |||
| Bug Depends on: | 324243, 324194 | ||
| Bug Blocks: | 324974, 322585 | ||
| Attachments: | |||
|
Description
Michael OBrien
>Roughly, the code should change from EntityManagerSetupImpl.375 if (isValidationOnly(deployProperties, false)) { > session.initializeDescriptors(); } else { if (isSessionLoadedFromSessionsXML) { if (!session.isConnected()) { session.login(); } } else { > login(session, deployProperties); } >to if (isValidationOnly(deployProperties, false)) { > session.loginAndDetectDatasource(); // NEW for 324213 > session.initializeDescriptors(); } else { if (isSessionLoadedFromSessionsXML) { if (!session.isConnected()) { session.login(); } } else { > login(session, deployProperties); } >where we now get auto-detected [EL Finest]: 2010-09-01 11:27:59.641--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.JavaDBPlatform, RegularExpression: (?i).*derby. [EL Fine]: 2010-09-01 11:27:59.641--Thread(Thread[main,5,main])--Detected Vendor platform: org.eclipse.persistence.platform.database.JavaDBPlatform [EL Config]: 2010-09-01 11:27:59.681--ServerSession(15184449)--Connection(30293957)--Thread(Thread[main,5,main])--connecting(DatabaseLogin( platform=>JavaDBPlatform Created attachment 177977 [details]
Patch to auto-detect database platform before initializeDescriptors when validation-only=True (a db login but not a full session.login())
>Alternative to logging into the database #2
The issue with validation-only=True is that if the target-database is not specified - we fail because we have not detected the database platform yet.
We can avoid a login to the database to get the vendor string by parsing the connection URL - this may a valid alternative to logging into the DB server
>Note: DB login when validation-only=True occurs on em.deploy() (no descriptor validation is done in emf.predeploy() >Just for reference: EE JTA injected EM fails on WebLogic 10.3.3.0 as expected When no target-database specified >Otherwise deployment works without target-database (for JTA) when validation is off <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="example" transaction-type="JTA"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <jta-data-source>localJTA</jta-data-source> <class>org.eclipse.persistence.example.jpa.server.business.Cell</class> <properties> <!-- 323148: force an early em.deploy() as part of the emf.predeploy() - normally done on first entityManager login --> <property name="eclipselink.validation-only" value="True"/> >Exception <2-Sep-2010 1:24:49 o'clock PM EDT> <Alert> <EclipseLink> <BEA-2005000> <2010-09-02 13:24:49.045--ServerSession(39163449)--Local Exception Stack: Exception [EclipseLink-7144] (Eclipse Persistence Services - 2.2.0.qualifier): org.eclipse.persistence.exceptions.ValidationException Exception Description: EL_CELL_SEQ: platform DatabasePlatform does not support NativeSequence. at org.eclipse.persistence.exceptions.ValidationException.platformDoesNotSupportSequence(ValidationException.java:1959) at org.eclipse.persistence.sequencing.NativeSequence.onConnect(NativeSequence.java:143) at org.eclipse.persistence.sequencing.Sequence.onConnect(Sequence.java:270) at org.eclipse.persistence.internal.sequencing.SequencingManager.onConnectAllSequences(SequencingManager.java:843) at org.eclipse.persistence.internal.sequencing.SequencingManager.onConnect(SequencingManager.java:706) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeSequencing(DatabaseSessionImpl.java:148) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:420) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:380) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:157) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:214) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:202) 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 weblogic.deployment.EntityManagerFactoryProxyImpl.invoke(EntityManagerFactoryProxyImpl.java:87) at $Proxy89.createEntityManager(Unknown Source) >in EntityManagerSetupImpl.deploy() if (isValidationOnly(deployProperties, false)) { session.initializeDescriptors(); Created attachment 178141 [details] Comment only patch for EntityManagerFactoryProvider - we will nofix and require that target-database is set when validation-only=True >After a review by the JPA team, the option to nofix this was suggested The change in EntityManagerFactoryProvider that would have called DB auto-detection and logged into the DB will not be done so we can preserve the "no login" behavior of validation. We will nofix and require that target-database property is set when validation-only=True >Validation users need to specify the database platform in order for full validation to occur
target-database property should be set when validation-only=True
Created attachment 178742 [details]
324213 patch3 add validation-only javadoc
Created attachment 178745 [details]
324213 patch3 add validation-only javadoc
>comment javadoc changes in 8165 and 8166
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |