Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated tapestry-jdo manual to jdo3 , tapestry-jdo 0.0.2
Info
titleVersion Status : 0.0.1 initial release, looking for feedback2 second release

Tested with Tapestry 5.2.x and 5.3.x

...

The Tynamo Tapestry-JDO module allows you to work with a JDO2 JDO3 (http://www.oracle.com/technetwork/java/index-jsp-135919.html) backed persistence layer, similarly to the way you would work w/ a JPA or Hibernate based persistence layer. JDO's main appeal is in its extensive support for ORM into relational databases (e.g. MySQL) as well as non-relational data stores (e.g. MongoDB through Datanucleus MongoDB Support, Google AppEngine JDO API, etc)

...

  • A dependency on org.tynamo:tapestry-jdo
  • A JDO implementation (we use datanucleus in our examples, but others such as Apache JDO should work as well). The implementations typically have some way of integrating the JDO Enhancement process into the build; although not absolutely necessary (e.g. you could probably do that manually after you run your build and before packaging your app), it would probably be a good idea
  • A properly configured jdoconfig.xml xml or persistence.xml

Add dependency on Tapestry-JDO

...

 

Code Block
titleMaven dependency for tapestry-jdo
languagehtml/xml
<!-- tynamo jdo related dependencies -->
<dependency>
   <groupId>org.tynamo</groupId>
   <artifactId>tapestry-jdo</artifactId>
   <version>2<version>0.0.2-SNAPSHOT<2</version>
</dependency>

Add your JDO implementation

Add your own dependencies for your JDO implementation if you're using something different:

 

Code Block
titleJDO Implementation Dependencies
languagehtml/xml
<dependency>
     <groupId>org.datanucleus</groupId>
     <artifactId>datanucleus-core</artifactId>
    <version>1 <version>3.1.5<2</version>
 </dependency>
<dependency>
     <groupId>org.datanucleus</groupId>
     <artifactId>datanucleus-api-jdo</artifactId>
     <version>3.1.2</version>
</dependency>
<dependency>
     <groupId>org.datanucleus</groupId>
     <artifactId>datanucleus-rdbms</artifactId>
    <version>1 <version>3.1.6<2</version>
</dependency>

Configure build to instrument your JDO classes:

Code Block
titleJDO Enhancer Configuration in Maven
languagehtml/xml
<build>
   .. 
   <plugins> 
          <!--
				This plug-in "enhances" your domain model objects (i.e. makes them
				persistent for datanucleus)
			-->
            <plugin>
                <groupId>org.datanucleus</groupId>
                <artifactId>maven-datanucleus-plugin</artifactId>
				
                <version>1<version>3.1.4<2</version>
                <configuration>
                    <metadataDirectory>target/classes</metadataDirectory>
       <!--             <metadataIncludes>**/entities/*.class</metadataIncludes>        
               Make sure this path contains your<verbose>true</verbose>
persistent classes!                   <enhancerName>ASM</enhancerName>
         --> 				          <api>JDO</api>
              <mappingIncludes>**/entities/*.class,**/internal/test/SampleEntity.class</mappingIncludes>  </configuration>
                <executions>
   <log4jConfiguration>${basedir}/src/main/resources/log4j.properties</log4jConfiguration>                 <execution>
                        <phase>compile</phase>
                    <verbose>true</verbose>    <goals>
                            <goal>enhance</goal>
                    <enhancerName>ASM</enhancerName>    </goals>
                    <api>JDO<</api>execution>
                </configuration>executions>
                <executions><dependencies>
                    <execution><dependency>
                        <phase>test-compile</phase><groupId>org.datanucleus</groupId>
                        <artifactId>datanucleus-core</artifactId>
                        <goals><version>3.1.2</version>
                        <scope>runtime</scope>
   <goal>enhance</goal>                     <exclusions>
                            <exclusion>
                                <groupId>javax.transaction</groupId>
                        </goals>        <artifactId>transaction-api</artifactId>
                            </execution>exclusion>
                        </executions>exclusions>
                <dependencies>    </dependency>
                    <dependency>
                        <groupId>org.datanucleus</groupId>
                        <artifactId>datanucleus-core<api-jdo</artifactId>
                        <version>1<version>3.1.5<2</version>
                    </dependency>
   <scope>runtime</scope>                 <dependency>
       <exclusions>                 <groupId>org.datanucleus</groupId>
           <exclusion>             <artifactId>datanucleus-rdbms</artifactId>
                   <groupId>javax.transaction</groupId>     <version>3.1.2</version>
                    </dependency>
           <artifactId>transaction-api</artifactId>         <dependency>
                   </exclusion>     <groupId>org.datanucleus</groupId>
                        <<artifactId>datanucleus-enhancer</exclusions>artifactId>
                        <version>3.1.1</version>
                    </dependency>
					                 </dependencies>
            </plugin>
        ....
      </plugins>
</build>
....

 

Add your persistence store driver :

Code Block
titleJDBC Driver Dependency
languagehtml/xml
<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
</dependency>

 

...

Code Block
titlejdoconfig.xml
languagehtml/xml
<?xml version="1.0" encoding="utf-8"?>
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
    <!--property name="javax.jdo.option.NontransactionalWrite" value="true"/-->
    <persistence-manager-factory name="testapp-pm">
        <property name="javax.jdo.PersistenceManagerFactoryClass" value="org.datanucleus.api.jdo.JDOPersistenceManagerFactory"/>
        <property name="javax.jdo.option.RetainValues" value="true"/>
		<property name="javax.jdo.option.ConnectionDriverName" value="org.h2.Driver" />
		<property name="javax.jdo.option.ConnectionURL" value="jdbc:h2:~/.h2/test-jdo-database" />
		<property name="javax.jdo.option.ConnectionUserName" value="" />
		<property name="javax.jdo.option.ConnectionPassword" value="" />
		<property name="datanucleus.autoCreateSchema" value="true" />
		<property name="datanucleus.validateTables" value="false" />
		<property name="datanucleus.validateConstraints" value="false" />
    </persistence-manager-factory>
</jdoconfig>

...