Defining EJB 3 Persistence Configuration

There are some persistence properties which are used for database connection. You need to set them before run the generated application.

  1. Open EJB 3 Persistence Configuration form from the model's property sheet.


  2. Select persistence provider you use. You should refer to compliance issues for some constraints with these persistence providers.
  3. 3. Define JDBC driver class, connection URL, JDBC driver jar file path, user name and password.

Option

Description

Persistence provider

Specifies the persistence provider to be used.

Transaction type

Specifies the transaction type to be used.

Data source

Specifies the data source name (if data source is used).

Add Dali support

Specifies that the generated project can be authored in Dali. A special Eclipse project builder and nature will be generated.

JDBC driver class

Specifies the JDBC driver class.

Connection URL

Specifies the JDBC connection URL string.

JDBC driver jar

Specifies the JDBC driver jar file path.

User name

Specifies the database user name.

Password

Specifies the database user password.

Cascade persist

Specifies whether to set the cascade style to PERSIST for all relationships in the persistent unit.

You can verify the configuration parameters in the Preview tab. The generated persistence configuration file looks like:

<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="EJB3_0Model" transaction-type="RESOURCE_LOCAL">
  <description>
  This is auto generated configuration for persistent unit EJB3_0Model  
  </description>
<provider>org.hibernate.ejb.HibernatePersistence</provider>
  <!-- mapped files -->
  <!--jar-file/-->
  <!-- mapped classes -->  
  <class>com.company.orders.Customer</class>
  <class>com.company.orders.Order</class>
  <properties>
   <property name="hibernate.dialect">org.hibernate.dialect.SybaseDialect</property>
   <property name="hibernate.connection.driver_class">com.sybase.jdbc2.jdbc.SybDriver</property>
   <property name="hibernate.connection.url">jdbc:sybase:Tds:localhost:5000/Production</property>
   <property name="hibernate.connection.username">sa</property>
   <property name="hibernate.connection.password"></property>
  </properties>
 </persistence-unit>
</persistence>