Java Reference
In-Depth Information
The entity Persistence Configuration file
The persistence.xml file is used to define the persistence unit/s, which includes
a JTA data source that is used for database persistence. The persistence provider is
specified as org.eclipse.persistence.jpa.PersistenceProvider . The jta-
data-source is defined as java:/app/jdbc/jdbc/OracleDBConnectionDS . The
eclipselink.target-server property is specified as WebLogic_10 . The javax.
persistence.jtaDataSource property is specified as java:/app/jdbc/jdbc/
OracleDBConnectionDS . The java:/app/jdbc prefix gets added to the JTA Data
Source specified when creating the persistence unit. Remove the java:/app/jdbc
prefix as we are using an external WebLogic server, not the integrated WebLogic
server. The persistence.xml configuration file is listed as follows:
<?xml version="1.0" encoding="windows-1252" ?>
<persistence 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"
version="1.0">
<persistence-unit name="em">
<provider>org.eclipse.persistence.jpa.PersistenceProvider
</provider>
<jta-data-source>jdbc/OracleDBConnectionDS</jta-data-source>
<class>model.Catalog</class>
<properties>
<property name="eclipselink.ddl-generation" value="none" />
<property name="eclipselink.target-server"
value="WebLogic_10" />
<property name="javax.persistence.jtaDataSource"
value="jdbc/OracleDBConnectionDS" />
<property name="eclipselink.target-database"
value="Oracle10g" />
</properties>
</persistence-unit>
</persistence>
Creating a stateless session bean
As we already discussed, it's always a good practice to create a session bean fa├žade
for an entity bean. This is done to ensure that the entity bean is not directly accessed
by a client. To create a session bean, follow the given steps:
1.
Select the EJB3Model project and select File | New .
2.
In the New Gallery window, select Categories | Business Tier | EJB and
Items | Session EJB . Click on OK .
 
Search WWH ::




Custom Search