Skip to content

Instantly share code, notes, and snippets.

@luizrobertofreitas
Forked from andreluizf/persistence.xml
Created July 7, 2014 18:11
Show Gist options
  • Save luizrobertofreitas/590febbe82836e1ce0ba to your computer and use it in GitHub Desktop.
Save luizrobertofreitas/590febbe82836e1ce0ba to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8" ?>
<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_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="order-old" transaction-type="RESOURCE_LOCAL">
<class>model.Order</class>
<class>model.OrderLine</class>
<class>model.Customer</class>
<properties>
<!-- Change this to access your own database. -->
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/test" />
<property name="javax.persistence.jdbc.user" value="test" />
<property name="javax.persistence.jdbc.password" value="password" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<!-- property name="eclipselink.logging.level" value="FINE" /-->
<property name="eclipselink.logging.level" value="off" />
</properties>
</persistence-unit>
<persistence-unit name="order" transaction-type="RESOURCE_LOCAL">
<class>model.Order</class>
<class>model.OrderLine</class>
<class>model.Customer</class>
<properties>
<!-- Change this to access your own database. -->
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:orcl" />
<property name="javax.persistence.jdbc.user" value="scott" />
<property name="javax.persistence.jdbc.password" value="tiger" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.logging.level" value="off" />
</properties>
</persistence-unit>
<persistence-unit name="order-opt" transaction-type="RESOURCE_LOCAL">
<!-- Optimization #7, 8 - sequence preallocation, query result cache -->
<mapping-file>META-INF/order-orm.xml</mapping-file>
<class>model.Order</class>
<class>model.OrderLine</class>
<class>model.Customer</class>
<properties>
<!-- Change this to access your own database. -->
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:orcl" />
<property name="javax.persistence.jdbc.user" value="scott" />
<property name="javax.persistence.jdbc.password" value="tiger" />
<property name="eclipselink.ddl-generation" value="create-tables" />
<!-- Optimization #9 - statement caching -->
<property name="eclipselink.jdbc.cache-statements" value="true" />
<!-- Optimization #10 - batch writing -->
<property name="eclipselink.jdbc.batch-writing" value="JDBC" />
<property name="eclipselink.jdbc.batch-writing.size" value="1000" />
<!-- Optimization #11 - disable caching for batch insert (caching only improves reads, so only adds overhead for inserts) -->
<property name="eclipselink.cache.shared.default" value="false" />
<!-- Except for Customer which is shared by orders -->
<property name="eclipselink.cache.shared.Customer" value="true" />
<!-- Optimization #12 - turn logging off -->
<!-- property name="eclipselink.logging.level" value="FINE" /-->
<property name="eclipselink.logging.level" value="off" />
<!-- Optimization #13 - close EntityManager on commit, to avoid cost of resume -->
<property name="eclipselink.persistence-context.close-on-commit" value="true" />
<!-- Optimization #14 - avoid auto flush cost on query execution -->
<property name="eclipselink.persistence-context.flush-mode" value="commit" />
<!-- Optimization #15 - avoid cost of persist on commit -->
<property name="eclipselink.persistence-context.persist-on-commit" value="true" />
</properties>
</persistence-unit>
</persistence>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment