Properties and config in persistence.xml

List of elements in persistence.xml

<!-- turn off 2nd level caching (optional), values: NONE, ALL, DISABLE_SELECTIVE, ENABLE_SELECTIVE,  -->

<!-- desired provider (optional), if not present, default provider will be used -->

<!-- if true, only listed classes will be treated as entities, default false, Not applicable for Java SE, where every entity must be listed -->

<!-- optional declaration of used datasource, if not specified, connection properties must be specified, otherwise will use specified datasrouce in container -->

These elements can be overriden by following properties, if a map is passed to EntityManagerFactory:

  • javax.persistence.provider to define the provider class used
  • javax.persistence.transactionType to define the transaction type used (either JTA or RESOURCE_LOCAL)
  • javax.persistence.jtaDataSource to define the JTA datasource name in JNDI
  • javax.persistence.nonJtaDataSource to define the non JTA datasource name in JNDI
  • javax.persistence.lock.timeout pessimistic lock timeout in milliseconds (Integer or String)
  • javax.persistence.query.timeout query timeout in milliseconds (Integer or String)
  • javax.persistence.sharedCache.mode corresponds to the share-cache-mode element defined in Section 2.2.1, “Packaging”.
  • javax.persistence.validation.mode corresponds to the validation-mode element defined in Section 2.2.1, “Packaging”.

See Hibernate 3.5 reference

List of standard properties


<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>


<property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/chapter02DB;create=true"/>


<property name="javax.persistence.jdbc.user" value="APP"/>


<property name="javax.persistence.jdbc.password" value="APP"/>


Hibernate properties

Debug SQL:

<property name="hibernate.show_sql" value="true"/>

Schema generation (optional):

<!-- create the database schema automatically, values: create-drop, update -->

<property name="" value="create-drop"/>


 <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />

EclipseLink properties

Schema generation (optional):

<!-- create the database schema automatically, values: create-tables, drop-and-create-tables -->

<property name="eclipselink.ddl-generation" value="create-tables"/>


Leave a Reply

Your email address will not be published. Required fields are marked *