Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/Examples/JPA/Migration/TopLinkEssentials"
m (→target-server) |
m (→Using the Package Rename Utility) |
||
(4 intermediate revisions by one other user not shown) | |||
Line 4: | Line 4: | ||
=== Persistence Provider === | === Persistence Provider === | ||
+ | Modify the persistence provider from | ||
− | = | + | <source lang="xml"> |
+ | <provider>oracle.toplink.essentials.PersistenceProvider</provider> | ||
+ | </source> | ||
− | + | or | |
+ | |||
+ | <source lang="xml"> | ||
+ | <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider> | ||
+ | </source> | ||
+ | |||
+ | to | ||
+ | |||
+ | <source lang="xml"> | ||
+ | <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> | ||
+ | </source> | ||
+ | |||
+ | === Properties === | ||
+ | When migrating the Persistence.xml the primary change in the persistence unit properties is converting from using "toplink.*" to "eclipselink.*" | ||
=== target-server === | === target-server === | ||
− | Verify in particular that you have the '''eclipselink.target-server''' property set - especially if you are | + | Verify in particular that you have the '''eclipselink.target-server''' property set - especially if you are migrating from TopLink Essentials to EclipseLink - where the '''provider''' and '''target-server''' were defaulted. |
*1) Check that your datasource is configured in transactional mode - usually the default. | *1) Check that your datasource is configured in transactional mode - usually the default. | ||
Line 22: | Line 38: | ||
</source> | </source> | ||
*3) Other things to verify | *3) Other things to verify | ||
− | **3a) If you check out the Glassfish V2 quickstart web tutorial, it is using the same persistence.xml format as your example. | + | **3a) If you check out the Glassfish V2 quickstart web tutorial, it is using the same persistence.xml format as your example. [http://wiki.eclipse.org/EclipseLink/Examples/JPA/GlassFishV2_Web_Tutorial EclipseLink JPA on GlassFish Web Quickstart Tutorial] |
− | [http://wiki.eclipse.org/EclipseLink/Examples/JPA/GlassFishV2_Web_Tutorial EclipseLink JPA on GlassFish Web Quickstart Tutorial] | + | |
**3b) To view a similar stateless session bean that uses an injected persistence unit, see the following code - notice that the ''em.persist()'' calls have no wrapper transaction calls. | **3b) To view a similar stateless session bean that uses an injected persistence unit, see the following code - notice that the ''em.persist()'' calls have no wrapper transaction calls. | ||
**See | **See | ||
Line 60: | Line 75: | ||
== Using the Package Rename Utility == | == Using the Package Rename Utility == | ||
+ | See [http://wiki.eclipse.org/EclipseLink/Examples/MigratingFromOracleTopLink#Rename_Packages Package Renamer] |
Latest revision as of 15:19, 5 March 2009
This how-to discusses how a user can migrate to using EclipseLink JPA from TopLink Essentials
Contents
Persistence.xml
Persistence Provider
Modify the persistence provider from
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
or
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
to
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
Properties
When migrating the Persistence.xml the primary change in the persistence unit properties is converting from using "toplink.*" to "eclipselink.*"
target-server
Verify in particular that you have the eclipselink.target-server property set - especially if you are migrating from TopLink Essentials to EclipseLink - where the provider and target-server were defaulted.
- 1) Check that your datasource is configured in transactional mode - usually the default.
- 2) Check your persistence.xml has a target-server property - this will affect transactions.
- Note: by default GlassFish V2 would have defaulted this "target-server" value when using TopLink Essentials because that persistence provider is the one loaded by default - When using the EclipseLink JPA provider.
You will need to specify target-server it in order to get server platform specific functionality surrounding a transaction manager acquire using "java:appserver/TransactionManager" in the SunAS9TransactionController.
<property name="eclipselink.target-server" value="SunAS9"/>
- 3) Other things to verify
- 3a) If you check out the Glassfish V2 quickstart web tutorial, it is using the same persistence.xml format as your example. EclipseLink JPA on GlassFish Web Quickstart Tutorial
- 3b) To view a similar stateless session bean that uses an injected persistence unit, see the following code - notice that the em.persist() calls have no wrapper transaction calls.
- See
- 3c) Note 1: if you are using a JTA datasource with a stateless session bean then you should not be managing your transactional state using begin or commit - the container will handle the transaction for you.
- 3d) Note 2: The attribute TransactionAttributeType.REQUIRED is the default state of the @TransactionAttribute annotation - so it does not change container managed behavior in this example.
- 3e) Note 3: If you are overriding default container managed transactions by specifying TransactionAttributeType at the class context level then verify that your @TransactionManagement annotations on every method are ok.
- 3f) Note 4: Verify that you have not changed the default TRANSACTION value for PersistenceContextType.EXTENDED in your client servlet or bean of the stateless session bean - or your transaction will extend beyond a single call to the SSB.
- 3g) Note 5: Depending on how your datasource is setup - If you are creating the datasource on the embedded tomcat servlet container and not on then be aware that you will require a session customizer to change the lookupType' on the JTA connector to JNDIConnector.STRING_LOOKUP
ORM.XML
TopLink Essentials uses the JPA 1.0 defined orm.xml schema and thus is compatible with EclipseLink. The only content changes that should be made is conversion of any query hints used in the configuration.
Query Hints
Annotations
Query Hints
Java API
Query Hints
- Java code: customer PU properties and query hints
- Use of EclipseLink native API where TLE native API was used
- Side-effects of the migration
- Change from default access type when using ORM.XML
Custom Mapping Definitions
Using the Package Rename Utility
See Package Renamer