You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by bu...@apache.org on 2014/05/26 12:31:54 UTC

svn commit: r909987 - in /websites/staging/isis/trunk: cgi-bin/ content/ content/components/objectstores/jdo/mapping-blobs.html

Author: buildbot
Date: Mon May 26 10:31:54 2014
New Revision: 909987

Log:
Staging update by buildbot for isis

Modified:
    websites/staging/isis/trunk/cgi-bin/   (props changed)
    websites/staging/isis/trunk/content/   (props changed)
    websites/staging/isis/trunk/content/components/objectstores/jdo/mapping-blobs.html

Propchange: websites/staging/isis/trunk/cgi-bin/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Mon May 26 10:31:54 2014
@@ -1 +1 @@
-1597304
+1597553

Propchange: websites/staging/isis/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Mon May 26 10:31:54 2014
@@ -1 +1 @@
-1597304
+1597553

Modified: websites/staging/isis/trunk/content/components/objectstores/jdo/mapping-blobs.html
==============================================================================
--- websites/staging/isis/trunk/content/components/objectstores/jdo/mapping-blobs.html (original)
+++ websites/staging/isis/trunk/content/components/objectstores/jdo/mapping-blobs.html Mon May 26 10:31:54 2014
@@ -403,13 +403,15 @@
 
 <p>As for <a href="mapping-joda-dates.html">Joda dates</a>, this requires the <code>@javax.jdo.annotations.Persistent</code> 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.</p>
 
+<h3>Mapping Blobs</h3>
+
 <p>For example, in the <code>ToDoItem</code> class (of the <a href="../../../getting-started/quickstart-archetype.html">quickstart archetype</a>) the <code>attachment</code> property (as of 1.5.0-snapshot) is as follows:</p>
 
 <pre>
   @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")
+      @javax.jdo.annotations.Column(name = "attachment_bytes", jdbcType="BLOB", sqlType = "BLOB")
   })
   private Blob attachment;
 
@@ -430,7 +432,7 @@
   @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")
+      @javax.jdo.annotations.Column(name = "attachment_bytes", jdbcType="BLOB", sqlType = "BLOB", allowsNull="false")
   })
   private Blob attachment;
 
@@ -447,26 +449,49 @@
   <p>Instead of <code>@Mandatory</code>, using <code>@javax.jdo.annotations.Column(allowsNull="false")</code> will also work.  However, as this last <code>@Column</code> annotation is only for Isis' benefit (DataNucleus ignores it in the presence of the <code>Persistent#columns</code> attribute) we prefer to use <code>@Mandatory</code> instead.</p>
 </blockquote>
 
-<p>Using the <code>@Column</code> annotation, you can also specify whether the <code>Blob</code> is mapped to a <code>VARBINARY</code> rather than a <code>BLOB</code> column:</p>
+<h3>Mapping Clobs</h3>
+
+<p>Mapping <code>Clob</code>s works in a very similar way, but the <code>@Column#sqlType</code> attribute will be <code>CLOB</code>:</p>
 
 <pre>
-      @javax.jdo.annotations.Column(name = "attachment_bytes", sqlType = "VARBINARY", length=2048)
+  @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_chars", sqlType = "CLOB")
+  })
+  private Clob doc;
+
+  @Mandatory
+  public Clob getDoc() {
+    return doc;
+  }
+  public void setDoc(final Clob doc) {
+    this.doc = doc;
+  }
+</pre>
+
+<p>or <code>VARCHAR</code>:</p>
+
+<pre>
+      @javax.jdo.annotations.Column(name = "attachment_chars", sqlType = "VARCHAR", length=2048)
 </pre>
 
-<p>The maximum allowed length for a <code>VARBINARY</code> will vary by database vendor.  Obviously, only do this if you are sure that the data to be mapped fits into the smaller size.  </p>
+<h1>Mapping to VARBINARY or VARCHAR</h1>
 
-<p>Mapping <code>Clob</code>s works the exact same way, but the <code>@Column#sqlType</code> attribute will either be <code>CLOB</code></p>
+<p>Instead of mapping to a <code>Blob</code> or <code>Clob</code> datatype, you might also specify map to a <code>VARBINARY</code> or <code>VARCHAR</code>.  In this case you will need to specify a length.  For example:</p>
 
 <pre>
-      @javax.jdo.annotations.Column(name = "attachment_chars", sqlType = "CLOB")
+      @javax.jdo.annotations.Column(name = "attachment_bytes", sqlType = "VARBINARY", length=2048)
 </pre>
 
-<p>or <code>VARCHAR</code>, </p>
+<p>or</p>
 
 <pre>
       @javax.jdo.annotations.Column(name = "attachment_chars", sqlType = "VARCHAR", length=2048)
 </pre>
 
+<p>Support and maximum allowed length will vary by database vendor.</p>
+
 
 
       </div>