Skip to content

Instantly share code, notes, and snippets.

@wesleyegberto
Last active December 28, 2016 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wesleyegberto/a661c16c8516e38d9c37fb01e371c4b2 to your computer and use it in GitHub Desktop.
Save wesleyegberto/a661c16c8516e38d9c37fb01e371c4b2 to your computer and use it in GitHub Desktop.
Dependencies e configs to test JPA using Derby (may need update)

#Dependencies e configs to test JPA using Derby

may need update

Dependecies to POM.xml

<dependency>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>eclipselink</artifactId>
    <version>2.6.0</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.apache.derby</groupId>
    <artifactId>derby</artifactId>
    <version>10.11.1.1</version>
    <scope>test</scope>
</dependency>
<!-- Just a class to facilitate the creation of EM -->
<dependency>
    <groupId>com.airhacks.rulz</groupId>
    <artifactId>em</artifactId>
    <version>0.0.2</version>
    <scope>test</scope>
</dependency>

Content of file in src/test/resources/persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 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_2_0.xsd">
    <persistence-unit name="it" transaction-type="RESOURCE_LOCAL">
        <class>com.airhacks.hello.business.order.entity.Order</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
        <properties>
            <property name="javax.persistence.jdbc.url" value="jdbc:derby:./${db};create=true"/>
            <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
            <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
        </properties>
    </persistence-unit>
</persistence>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment