Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "Configuring a EclipseLink JPA Application (ELUG)"

m (Configuring Oracle Database Proxy Authentication for a JPA Application)
m (Configuring Oracle Database Proxy Authentication for a JPA Application)
Line 16: Line 16:
 
===How to Provide Authenticated Reads and Writes of Secured Data Through the Use of an Exclusive Isolated Client Session===
 
===How to Provide Authenticated Reads and Writes of Secured Data Through the Use of an Exclusive Isolated Client Session===
  
If you use Oracle VPD (Section 94.5.1, "Isolated Client Sessions and Oracle Virtual Private Database (VPD)"), and you want to [[Introduction%20to%20Data%20Access%20(ELUG)#Providing Authenticated Reads and Writes of Secured Data Through the Use of an Exclusive Isolated Client Session|provide read and write access control]] for your EclipseLink JPA application, in the [[Customizing%20the%20EclipseLink%20Application%20(ELUG)#Using the Session Customizer Class|SessionCustomizer]] class set the connection policy to use exclusive connections, and set the descriptor for secured data to isolated (Section 127.13, "Configuring Cache Isolation at the Descriptor Level"). Consider the following example.
+
If you use Oracle VPD (Section 94.5.1, "Isolated Client Sessions and Oracle Virtual Private Database (VPD)"), and you want to [[Introduction%20to%20Data%20Access%20(ELUG)#Providing Authenticated Reads and Writes of Secured Data Through the Use of an Exclusive Isolated Client Session|enable read and write access control]] for your EclipseLink JPA application, in the [[Customizing%20the%20EclipseLink%20Application%20(ELUG)#Using the Session Customizer Class|SessionCustomizer]] class set the connection policy to use exclusive connections, and set the descriptor for secured data to isolated (see [[Configuring%20a%20Descriptor%20(ELUG)#Configuring Cache Isolation at the Descriptor Level|Configuring Cache Isolation at the Descriptor Level). Consider the following example.
  
 
<span id="Example 199-1"></span>
 
<span id="Example 199-1"></span>
Line 46: Line 46:
  
 
===How to Provide Authenticated Writes for Database Auditing Purposes with a Client Session===
 
===How to Provide Authenticated Writes for Database Auditing Purposes with a Client Session===
If you want to [[Introduction%20to%20Data%20Access%20(ELUG)#Providing Authenticated Writes for Database Auditing Purposes with a Client Session|provide write access control]] for your EclipseLink JPA application, specify in the [[Customizing%20the%20EclipseLink%20Application%20(ELUG)#Using the Session Customizer Class|SessionCustomizer]] that an exclusive connection should be used. For more information, see [[Configuring%20a%20Database%20Login%20(ELUG)#SessionCustomizer-config|Configuring Session Login Using SessionCustomizer]].
+
If you want to [[Introduction%20to%20Data%20Access%20(ELUG)#Providing Authenticated Writes for Database Auditing Purposes with a Client Session|enable write access control]] for your EclipseLink JPA application, in your [[Customizing%20the%20EclipseLink%20Application%20(ELUG)#Using the Session Customizer Class|SessionCustomizer]] class provide the <tt>EntityManager</tt> with properties similar to the ones that the following example demonstrates.
  
The next step is to pass one or more properties to the <tt>createEntityManagerFactory</tt> method, as the following example demonstrates. These properties should indicate that one or more specific entities use an isolated cache.
+
Map emProperties = new HashMap();
 +
emProperties.put("eclipselink.oracle.proxy-type", oracle.jdbc.OracleConnection.PROXYTYPE_USER_NAME);
 +
emProperties.put(oracle.jdbc.OracleConnection.PROXY_USER_NAME, "john");
 +
EntityManager em = emFactory.createEntityManager(emProperties);
  
Map properties = new HashMap();
+
In the preceding example, the <tt>EntityManager</tt> uses a proxy user "john" for writes and reads inside a transaction. Note that reads, which are performed outside of the transaction, are done through the main (non-proxied) connection.
properties.put("eclipselink.cache.shared.Employee", "false");
+
...
+
EntityManagerFactory emf = Persistence.createEntityManagerFactory(properties);
+
  
In the preceding example, an entity named <tt>Employee</tt> uses isolated cache and will be read and written through an exclusive connection.
+
If you created your <tt>EntityManager</tt> using injection, set the properties as follows:
 +
 
 +
((org.eclipse.persistence.internal.jpa.EntityManagerImpl)em.getDelegate()).setProperties(emProperties);
  
 
For more information, see [[Using%20EclipseLink%20JPA%20Extensions%20(ELUG)#How to Use the Persistence Unit Properties for Caching|How to Use the Persistence Unit Properties for Caching]].
 
For more information, see [[Using%20EclipseLink%20JPA%20Extensions%20(ELUG)#How to Use the Persistence Unit Properties for Caching|How to Use the Persistence Unit Properties for Caching]].

Revision as of 11:49, 13 June 2008

This section contains information on how you can configure your EclipseLink persistence project.

When configuring an EclipseLink JPA application you cannot use the org.eclipselink.sessions.Project class, but you can still customize sessions and descriptors by using the customizer extensions (see Using EclipseLink JPA Extensions for Customization and Optimization).

You can set up your EclipseLink JPA application using various IDEs.

At run time, if the eclipselink.jar file is on the application classpath, you have the option to choose EclipseLink as a persistence provider for your application.


Configuring Oracle Database Proxy Authentication for a JPA Application

One of the features of the Oracle Database is proxy authentication. For more information, see Oracle Database Proxy Authentication.


How to Provide Authenticated Reads and Writes of Secured Data Through the Use of an Exclusive Isolated Client Session

If you use Oracle VPD (Section 94.5.1, "Isolated Client Sessions and Oracle Virtual Private Database (VPD)"), and you want to enable read and write access control for your EclipseLink JPA application, in the SessionCustomizer class set the connection policy to use exclusive connections, and set the descriptor for secured data to isolated (see [[Configuring a Descriptor (ELUG)#Configuring Cache Isolation at the Descriptor Level|Configuring Cache Isolation at the Descriptor Level). Consider the following example.

Specifying the Use of an Exclusive Connection

Login login = server.getDatasourceLogin();
// Make sure that external connection pooling is used
login.setUsesExternalConnectionPooling(true);
...
ConnectionPolicy policy = server.getDefaultConnectionPolicy();
...
// Set the connection policy to exclusive
policy.setShouldUseExclusiveConnection(true);

The next step is to pass one or more properties to the createEntityManagerFactory method, as the following example demonstrates. These properties should indicate that one or more specific entities use an isolated cache.

Map properties = new HashMap();
properties.put("eclipselink.cache.shared.Employee", "false");
...
EntityManagerFactory emf = Persistence.createEntityManagerFactory(properties);

In the preceding example, an entity named Employee uses isolated cache and will be read and written through an exclusive connection.

To specify that all entities are to use isolated cache, set the eclipselink.cache.shared.default property to false:

properties.put("eclipselink.cache.shared.default", "false");

For more information, see How to Use the Persistence Unit Properties for Caching.


How to Provide Authenticated Writes for Database Auditing Purposes with a Client Session

If you want to enable write access control for your EclipseLink JPA application, in your SessionCustomizer class provide the EntityManager with properties similar to the ones that the following example demonstrates.

Map emProperties = new HashMap();
emProperties.put("eclipselink.oracle.proxy-type", oracle.jdbc.OracleConnection.PROXYTYPE_USER_NAME);
emProperties.put(oracle.jdbc.OracleConnection.PROXY_USER_NAME, "john");
EntityManager em = emFactory.createEntityManager(emProperties);

In the preceding example, the EntityManager uses a proxy user "john" for writes and reads inside a transaction. Note that reads, which are performed outside of the transaction, are done through the main (non-proxied) connection.

If you created your EntityManager using injection, set the properties as follows:

((org.eclipse.persistence.internal.jpa.EntityManagerImpl)em.getDelegate()).setProperties(emProperties);

For more information, see How to Use the Persistence Unit Properties for Caching.

Setting Up Packaging

You can package your application manually (see Packaging an EclipseLink JPA Application), or use an IDE.




Copyright Statement

Back to the top