You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2014/05/24 07:56:27 UTC

svn commit: r1597244 - in /isis/site/trunk/content: ./ components/objectstores/jdo/ components/objectstores/jdo/services/ intro/getting-started/ other/

Author: danhaywood
Date: Sat May 24 05:56:26 2014
New Revision: 1597244

URL: http://svn.apache.org/r1597244
Log:
mapping blobs; 1.4.2->1.5.0; fork me on github

Modified:
    isis/site/trunk/content/components/objectstores/jdo/IsisConfigurationForJdoIntegTests.md
    isis/site/trunk/content/components/objectstores/jdo/mapping-blobs.md
    isis/site/trunk/content/components/objectstores/jdo/services/publishing-service-jdo.md
    isis/site/trunk/content/documentation.md
    isis/site/trunk/content/intro/getting-started/quickstart-archetype.md
    isis/site/trunk/content/intro/getting-started/simple-archetype.md
    isis/site/trunk/content/other/jrebel.md

Modified: isis/site/trunk/content/components/objectstores/jdo/IsisConfigurationForJdoIntegTests.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/components/objectstores/jdo/IsisConfigurationForJdoIntegTests.md?rev=1597244&r1=1597243&r2=1597244&view=diff
==============================================================================
--- isis/site/trunk/content/components/objectstores/jdo/IsisConfigurationForJdoIntegTests.md (original)
+++ isis/site/trunk/content/components/objectstores/jdo/IsisConfigurationForJdoIntegTests.md Sat May 24 05:56:26 2014
@@ -1,4 +1,4 @@
-Title: `IsisConfigurationForJdoIntegTests` (1.4.2-snapshot)
+Title: `IsisConfigurationForJdoIntegTests` (1.5.0-snapshot)
 
 When running integration tests with the JDO Objectstore, there are certain standard configuration properties that are usually set.  For example, integration tests are usually run against an in-memory HSQLDB database.
 

Modified: isis/site/trunk/content/components/objectstores/jdo/mapping-blobs.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/components/objectstores/jdo/mapping-blobs.md?rev=1597244&r1=1597243&r2=1597244&view=diff
==============================================================================
--- isis/site/trunk/content/components/objectstores/jdo/mapping-blobs.md (original)
+++ isis/site/trunk/content/components/objectstores/jdo/mapping-blobs.md Sat May 24 05:56:26 2014
@@ -1,19 +1,22 @@
-Title: Mapping Blobs
+Title: Mapping Blobs (and Clobs)
 
+> *Note:* prior to 1.5.0-snapshot, the Isis mapping for `Blob`s and `Clob`s is broken (the mapping classes are not correctly registered with DataNucleus), and so the `Blob` or `Clob` are stored as a serialized Java object... not ideal.
 
 Isis configures JDO/DataNucleus so that the properties of type `org.apache.isis.applib.value.Blob` and `org.apache.isis.applib.value.Clob` can also be persisted.
 
 As for [Joda dates](mapping-joda-dates.html), this requires the `@javax.jdo.annotations.Persistent` annotation.  However, whereas for dates one would always expect this value to be retrieved eagerly, for blobs and clobs it is not so clear cut.
 
-For example, in the `ToDoItem` (in the [wicket/restful/jdo archetype](../../../getting-started/quickstart-archetype.html)) the `attachment` property is as follows:
+For example, in the `ToDoItem` class (of the [quickstart archetype](../../../getting-started/quickstart-archetype.html)) the `attachment` property (as of 1.5.0-snapshot) is as follows:
 
 <pre>
-  @javax.jdo.annotations.Persistent(defaultFetchGroup="false")
+  @javax.jdo.annotations.Persistent(defaultFetchGroup="false", columns = {
+      @javax.jdo.annotations.Column(name = "attachment_name"),
+      @javax.jdo.annotations.Column(name = "attachment_mimetype"),
+      @javax.jdo.annotations.Column(name = "attachment_bytes", sqlType = "BLOB")
+  })
   private Blob attachment;
 
   @Optional
-  @MemberOrder(name="Detail", sequence = "7")
-  @Hidden(where=Where.STANDALONE_TABLES)
   public Blob getAttachment() {
     return attachment;
   }
@@ -22,5 +25,46 @@ For example, in the `ToDoItem` (in the [
   }
 </pre>
 
-Here we can see that the property is hidden in standalone tables, and so there's no need to retrieve it eagerly.  The converse of this the object is rendered by itself, then the attachment property will be retrieved as a one separate query; this seems like a reasonable compromise.
+The three `@javax.jdo.annotations.Column` annotations are required because the mapping classes that Isis provides ([IsisBlobMapping](https://github.com/apache/isis/blob/isis-1.4.0/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/valuetypes/IsisBlobMapping.java#L59) and [IsisClobMapping](https://github.com/apache/isis/blob/isis-1.4.0/component/objectstore/jdo/jdo-datanucleus/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/valuetypes/IsisClobMapping.java#L59)) map to 3 columns.  (It is not an error to omit these `@Column` annotations, but without them the names of the table columns are simply suffixed `_0`, `_1`, `_2` etc.
+
+If the `Blob` or `Clob` is mandatory, then use:
+
+<pre>
+  @javax.jdo.annotations.Persistent(defaultFetchGroup="false", columns = {
+      @javax.jdo.annotations.Column(name = "attachment_name", allowsNull="false"),
+      @javax.jdo.annotations.Column(name = "attachment_mimetype", allowsNull="false"),
+      @javax.jdo.annotations.Column(name = "attachment_bytes", sqlType = "BLOB", allowsNull="false")
+  })
+  private Blob attachment;
+
+  @Mandatory
+  public Blob getAttachment() {
+    return attachment;
+  }
+  public void setAttachment(final Blob attachment) {
+    this.attachment = attachment;
+  }
+</pre>
+
+> Instead of `@Mandatory`, using `@javax.jdo.annotations.Column(allowsNull="false")` will also work.  However, as this last `@Column` annotation is only for Isis' benefit (DataNucleus ignores it in the presence of the `Persistent#columns` attribute) we prefer to use `@Mandatory` instead.
+
+Using the `@Column` annotation, you can also specify whether the `Blob` is mapped to a `VARBINARY` rather than a `BLOB` column:
+
+<pre>
+      @javax.jdo.annotations.Column(name = "attachment_bytes", sqlType = "VARBINARY", length=2048)
+</pre>
+
+The maximum allowed length for a `VARBINARY` will vary by database vendor.  Obviously, only do this if you are sure that the data to be mapped fits into the smaller size.  
+
+Mapping `Clob`s works the exact same way, but the `@Column#sqlType` attribute will either be `CLOB`
+
+<pre>
+      @javax.jdo.annotations.Column(name = "attachment_chars", sqlType = "CLOB")
+</pre>
+
+or `VARCHAR`, 
+
+<pre>
+      @javax.jdo.annotations.Column(name = "attachment_chars", sqlType = "VARCHAR", length=2048)
+</pre>
 

Modified: isis/site/trunk/content/components/objectstores/jdo/services/publishing-service-jdo.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/components/objectstores/jdo/services/publishing-service-jdo.md?rev=1597244&r1=1597243&r2=1597244&view=diff
==============================================================================
--- isis/site/trunk/content/components/objectstores/jdo/services/publishing-service-jdo.md (original)
+++ isis/site/trunk/content/components/objectstores/jdo/services/publishing-service-jdo.md Sat May 24 05:56:26 2014
@@ -8,7 +8,7 @@ The intention is for an event service bu
 
 Although a polling architecture introduces some overhead, it avoids the complexity of XA/JTA transactions which would otherwise be needed to ensure that events are only published atomically with committed changes to the database.
 
-## Configuration [1.4.2-snapshot]
+## Configuration [1.5.0-snapshot]
 
 The `PublishedEvent` entity can either persist the serialized form of the event as a zipped byte array or as a CLOB.  Which is used is determined by a configuration setting (typically stored in `persistor_datanucleus.properties`, but `isis.properties` can also be used):
 

Modified: isis/site/trunk/content/documentation.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/documentation.md?rev=1597244&r1=1597243&r2=1597244&view=diff
==============================================================================
--- isis/site/trunk/content/documentation.md (original)
+++ isis/site/trunk/content/documentation.md Sat May 24 05:56:26 2014
@@ -532,7 +532,7 @@ Other
 * [Using a JNDI Datasource](components/objectstores/jdo/using-jndi-datasource.html)
 * [Enabling Logging](components/objectstores/jdo/enabling-logging.html)
 * [Deploying on the Google App Engine](components/objectstores/jdo/deploying-on-the-google-app-engine.html)
-* [`IsisConfigurationForJdoIntegTests`](components/objectstores/jdo/IsisConfigurationForJdoIntegTests.html) (1.4.2-snapshot)
+* [`IsisConfigurationForJdoIntegTests`](components/objectstores/jdo/IsisConfigurationForJdoIntegTests.html) (1.5.0-snapshot)
 
 }
 

Modified: isis/site/trunk/content/intro/getting-started/quickstart-archetype.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/intro/getting-started/quickstart-archetype.md?rev=1597244&r1=1597243&r2=1597244&view=diff
==============================================================================
--- isis/site/trunk/content/intro/getting-started/quickstart-archetype.md (original)
+++ isis/site/trunk/content/intro/getting-started/quickstart-archetype.md Sat May 24 05:56:26 2014
@@ -70,7 +70,7 @@ This can also be accomplished using an e
 
     mvn antrun:run
 
-> in 1.4.2-snapshot this is changing to: mvn -P self-host antrun:run
+> in 1.5.0-snapshot this is changing to: mvn -P self-host antrun:run
 
 The first is to simply deploying the generated WAR (`webapp/target/myapp-webapp-1.0-SNAPSHOT.war`) to a servlet container.
 

Modified: isis/site/trunk/content/intro/getting-started/simple-archetype.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/intro/getting-started/simple-archetype.md?rev=1597244&r1=1597243&r2=1597244&view=diff
==============================================================================
--- isis/site/trunk/content/intro/getting-started/simple-archetype.md (original)
+++ isis/site/trunk/content/intro/getting-started/simple-archetype.md Sat May 24 05:56:26 2014
@@ -52,7 +52,7 @@ This can also be accomplished using an e
 
     mvn antrun:run
 
-> in 1.4.2-snapshot this is changing to: mvn -P self-host antrun:run
+> in 1.5.0-snapshot this is changing to: mvn -P self-host antrun:run
     
 The first is to simply deploying the generated WAR (`webapp/target/myapp-webapp-1.0-SNAPSHOT.war`) to a servlet container.
 

Modified: isis/site/trunk/content/other/jrebel.md
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/other/jrebel.md?rev=1597244&r1=1597243&r2=1597244&view=diff
==============================================================================
--- isis/site/trunk/content/other/jrebel.md (original)
+++ isis/site/trunk/content/other/jrebel.md Sat May 24 05:56:26 2014
@@ -35,9 +35,9 @@ The `dom` module requires a `rebel.xml` 
 
 Note the use of the `${project.root}` and `${target.dir}` properties; values are supplied when the application is launched (as explained below).
 
-> Prior to 1.4.2-snapshot, the `rebel.xml` file simply had hard-coded values within it.
+> Prior to 1.5.0-snapshot, the `rebel.xml` file simply had hard-coded values within it.
 
-## <a name="maven"><a name="screencast">Using Maven with JRebel (1.4.2-snapshot)</a></a>
+## <a name="maven"><a name="screencast">Using Maven with JRebel (1.5.0-snapshot)</a></a>
 
 This screencast shows how to use Maven in conjunction with JRebel: