Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Examples/JPA/Derby"

m (Retrofitting an existing Java SE application to use Derby)
m (EE persistence.xml)
Line 6: Line 6:
 
[[Image:Weblogic_derby_jta_datasource_setup.JPG]]
 
[[Image:Weblogic_derby_jta_datasource_setup.JPG]]
 
===EE persistence.xml===
 
===EE persistence.xml===
 +
<source lang="java">
 +
<persistence version="1.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_1_0.xsd">
 +
    <persistence-unit name="example" transaction-type="JTA">
 +
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
 +
        <jta-data-source>localJTA</jta-data-source>
 +
        <!-- optional --><class>org.eclipse.persistence.example.business.Cell</class>
 +
        <properties>
 +
            <!-- optional --><property name="eclipselink.target-database"
 +
                      value="org.eclipse.persistence.platform.database.DerbyPlatform"/>
 +
            <property name="eclipselink.target-server" value="WebLogic_10"/>
 +
            <property name="eclipselink.logging.level" value="FINEST"/>
 +
        </properties>     
 +
    </persistence-unit>
 +
</persistence>
 +
 +
</source>
 +
 
===SE persistence.xml===
 
===SE persistence.xml===
 
<source lang="java">
 
<source lang="java">

Revision as of 12:41, 4 December 2009

Running EclipseLink on the Derby Database

  • Running EclipseLink on derby has several advantages including ease of installation and small footprint for rapid development - and the fact that it is also open source like EclipseLink.
  • This tutorial is currently working with Derby 10.5.3.0.

Retrofitting an existing Java SE application to use Derby

WebLogic Server Console configuration

Weblogic derby jta datasource setup.JPG

EE persistence.xml

<persistence version="1.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_1_0.xsd">
    <persistence-unit name="example" transaction-type="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>localJTA</jta-data-source>
        <!-- optional --><class>org.eclipse.persistence.example.business.Cell</class>
        <properties>
            <!-- optional --><property name="eclipselink.target-database" 
                      value="org.eclipse.persistence.platform.database.DerbyPlatform"/>
            <property name="eclipselink.target-server" value="WebLogic_10"/>
            <property name="eclipselink.logging.level" value="FINEST"/>
        </properties>       
    </persistence-unit>
</persistence>

SE persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
  <persistence-unit name="dao.create.tables.derby" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>org.eclipse.persistence.example.jpa.server.business.Cell</class>
    <properties>
      <property name="eclipselink.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
      <property name="eclipselink.target-database" value="Derby"/>            
      <property name="eclipselink.jdbc.url" value="jdbc:derby://localhost:1527/weblogic;create=true"/>
      <property name="eclipselink.jdbc.user" value="APP"/>
      <property name="eclipselink.jdbc.password" value="APP"/>
      <property name="eclipselink.logging.level" value="ALL"/>            
      <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
      <property name="eclipselink.ddl-generation.output-mode" value="database"/>
    </properties>
  </persistence-unit>
</persistence>

Add derby jars

  • SE: Add derby jars to the application classpath
  • EE: Add derby jars to the application server classpath (Example: for WebLogic place in the modules directory)

References

  • Originated 20091113 for Derby 10.5.3.0

Back to the top