Author: sohil.shah(a)jboss.com
Date: 2009-01-13 16:34:32 -0500 (Tue, 13 Jan 2009)
New Revision: 12491
Removed:
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/blobs/TestBlobPortability.java
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/CMSEntry.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/HibernateStore.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/MaterializedBlobType.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/RepositoryEntry.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/VersionEntry.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/VersionBinVal.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/WSPBinVal.java
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/blobs/TestBlobPortabilityTestCase.java
modules/cms/trunk/cms-jackrabbit/src/test/resources/blobs.hbm.xml
modules/cms/trunk/cms-jackrabbit/src/test/resources/domain.hbm.xml
modules/cms/trunk/cms-jackrabbit/src/test/resources/hibernate.cfg.xml
modules/cms/trunk/cms-jackrabbit/src/test/resources/jboss-unit.xml
Log:
backing code (testsuite finally passed in single/multi-db mode without any special
postgresqlness)
looking at more optimization
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/CMSEntry.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/CMSEntry.java 2009-01-13
20:50:30 UTC (rev 12490)
+++
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/CMSEntry.java 2009-01-13
21:34:32 UTC (rev 12491)
@@ -33,7 +33,7 @@
private Integer key;
private String path;
private String name;
- private byte[] data;
+ private java.sql.Blob data;
private long lastmod;
private long length;
@@ -41,7 +41,7 @@
{
}
- public CMSEntry(String path, String name, byte[] data, long lastmod, long length)
+ public CMSEntry(String path, String name, java.sql.Blob data, long lastmod, long
length)
{
this.key = null;
this.path = path;
@@ -81,12 +81,12 @@
this.name = name;
}
- public byte[] getData()
+ public java.sql.Blob getData()
{
return data;
}
- public void setData(byte[] data)
+ public void setData(java.sql.Blob data)
{
this.data = data;
}
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/HibernateStore.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/HibernateStore.java 2009-01-13
20:50:30 UTC (rev 12490)
+++
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/HibernateStore.java 2009-01-13
21:34:32 UTC (rev 12491)
@@ -868,9 +868,11 @@
List rs = query.list();
//
Iterator iter = rs.iterator();
- byte[] blob = (byte[])iter.next();
+ //byte[] blob = (byte[])iter.next();
+ //return new ByteArrayInputStream(blob);
- return new ByteArrayInputStream(blob);
+ java.sql.Blob blob = (java.sql.Blob)iter.next();
+ return blob.getBinaryStream();
}
catch (Exception e)
{
@@ -946,11 +948,14 @@
throw new Exception("No such Entry " + name);
}
- versionEntry.setData(IOTools.getBytes(in));
+ //versionEntry.setData(IOTools.getBytes(in));
+ versionEntry.setData(Hibernate.createBlob(in));
+
versionEntry.setLastmod(System.currentTimeMillis());
versionEntry.setLength(length);
session.save(versionEntry);
+ session.flush();
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
@@ -963,11 +968,14 @@
throw new Exception("No such Entry " + name);
}
- cmsEntry.setData(IOTools.getBytes(in));
+ //cmsEntry.setData(IOTools.getBytes(in));
+ cmsEntry.setData(Hibernate.createBlob(in));
+
cmsEntry.setLastmod(System.currentTimeMillis());
cmsEntry.setLength(length);
session.save(cmsEntry);
+ session.flush();
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
@@ -980,11 +988,14 @@
throw new Exception("No such Entry " + name);
}
- repoEntry.setData(IOTools.getBytes(in));
+ //repoEntry.setData(IOTools.getBytes(in));
+ repoEntry.setData(Hibernate.createBlob(in));
+
repoEntry.setLastmod(System.currentTimeMillis());
repoEntry.setLength(length);
session.save(repoEntry);
+ session.flush();
}
}
catch (Exception e)
@@ -1008,18 +1019,27 @@
in = new FileInputStream(f);
if
(schemaObjectPrefix.equals(HibernateStoreConstants.versionClassName))
{
- VersionEntry versionEntry = new VersionEntry(parentDir, name,
IOTools.getBytes(in), System.currentTimeMillis(), length);
+ //VersionEntry versionEntry = new VersionEntry(parentDir,
name, IOTools.getBytes(in), System.currentTimeMillis(), length);
+ VersionEntry versionEntry = new VersionEntry(parentDir, name,
Hibernate.createBlob(in), System.currentTimeMillis(), length);
+
session.save(versionEntry);
+ session.flush();
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
- CMSEntry cmsEntry = new CMSEntry(parentDir, name,
IOTools.getBytes(in), System.currentTimeMillis(), length);
+ //CMSEntry cmsEntry = new CMSEntry(parentDir, name,
IOTools.getBytes(in), System.currentTimeMillis(), length);
+ CMSEntry cmsEntry = new CMSEntry(parentDir, name,
Hibernate.createBlob(in), System.currentTimeMillis(), length);
+
session.save(cmsEntry);
+ session.flush();
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
- RepositoryEntry repoEntry = new RepositoryEntry(parentDir,
name, IOTools.getBytes(in), System.currentTimeMillis(), length);
+ //RepositoryEntry repoEntry = new RepositoryEntry(parentDir,
name, IOTools.getBytes(in), System.currentTimeMillis(), length);
+ RepositoryEntry repoEntry = new RepositoryEntry(parentDir, name,
Hibernate.createBlob(in), System.currentTimeMillis(), length);
+
session.save(repoEntry);
+ session.flush();
}
}
catch (Exception e)
@@ -1149,11 +1169,14 @@
throw new Exception("No such Entry " + name);
}
- versionEntry.setData(IOTools.getBytes(in));
+ //versionEntry.setData(IOTools.getBytes(in));
+ versionEntry.setData(Hibernate.createBlob(in));
+
versionEntry.setLastmod(System.currentTimeMillis());
versionEntry.setLength(length);
session.save(versionEntry);
+ session.flush();
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
@@ -1166,11 +1189,14 @@
throw new Exception("No such Entry " + name);
}
- cmsEntry.setData(IOTools.getBytes(in));
+ //cmsEntry.setData(IOTools.getBytes(in));
+ cmsEntry.setData(Hibernate.createBlob(in));
+
cmsEntry.setLastmod(System.currentTimeMillis());
cmsEntry.setLength(length);
session.save(cmsEntry);
+ session.flush();
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
@@ -1183,11 +1209,15 @@
throw new Exception("No such Entry " + name);
}
- repoEntry.setData(IOTools.getBytes(in));
+ //repoEntry.setData(IOTools.getBytes(in));
+ repoEntry.setData(Hibernate.createBlob(in));
+
+
repoEntry.setLastmod(System.currentTimeMillis());
repoEntry.setLength(length);
session.save(repoEntry);
+ session.flush();
}
}
catch (Exception e)
@@ -1211,18 +1241,27 @@
in = IOTools.safeBufferedWrapper(new FileInputStream(f));
if
(schemaObjectPrefix.equals(HibernateStoreConstants.versionClassName))
{
- VersionEntry versionEntry = new VersionEntry(parentDir, name,
IOTools.getBytes(in), System.currentTimeMillis(), length);
+ //VersionEntry versionEntry = new VersionEntry(parentDir,
name, IOTools.getBytes(in), System.currentTimeMillis(), length);
+ VersionEntry versionEntry = new VersionEntry(parentDir, name,
Hibernate.createBlob(in), System.currentTimeMillis(), length);
+
session.save(versionEntry);
+ session.flush();
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
- CMSEntry cmsEntry = new CMSEntry(parentDir, name,
IOTools.getBytes(in), System.currentTimeMillis(), length);
+ //CMSEntry cmsEntry = new CMSEntry(parentDir, name,
IOTools.getBytes(in), System.currentTimeMillis(), length);
+ CMSEntry cmsEntry = new CMSEntry(parentDir, name,
Hibernate.createBlob(in), System.currentTimeMillis(), length);
+
session.save(cmsEntry);
+ session.flush();
}
else if
(schemaObjectPrefix.equals(HibernateStoreConstants.repositoryClassName))
{
- RepositoryEntry repoEntry = new RepositoryEntry(parentDir,
name, IOTools.getBytes(in), System.currentTimeMillis(), length);
+ //RepositoryEntry repoEntry = new RepositoryEntry(parentDir,
name, IOTools.getBytes(in), System.currentTimeMillis(), length);
+ RepositoryEntry repoEntry = new RepositoryEntry(parentDir, name,
Hibernate.createBlob(in), System.currentTimeMillis(), length);
+
session.save(repoEntry);
+ session.flush();
}
}
catch (Exception e)
@@ -1469,6 +1508,7 @@
VersionEntry versionEntry = new VersionEntry(parentDir, name, null,
System.currentTimeMillis(), 0);
session.save(versionEntry);
+ session.flush();
}
else if (schemaObjectPrefix.equals(HibernateStoreConstants.cmsClassName))
{
@@ -1481,6 +1521,7 @@
RepositoryEntry repoEntry = new RepositoryEntry(parentDir, name, null,
System.currentTimeMillis(), 0);
session.save(repoEntry);
+ session.flush();
}
}
catch (Exception e)
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/MaterializedBlobType.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/MaterializedBlobType.java 2009-01-13
20:50:30 UTC (rev 12490)
+++
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/MaterializedBlobType.java 2009-01-13
21:34:32 UTC (rev 12491)
@@ -9,25 +9,31 @@
*
* @author Steve Ebersole
*/
-public class MaterializedBlobType extends AbstractBynaryType {
+public class MaterializedBlobType extends AbstractBynaryType
+{
- public int sqlType() {
+ public int sqlType()
+ {
return Types.BLOB;
}
- public String getName() {
+ public String getName()
+ {
return "materialized-blob";
}
- public Class getReturnedClass() {
+ public Class getReturnedClass()
+ {
return byte[].class;
}
- protected Object toExternalFormat(byte[] bytes) {
+ protected Object toExternalFormat(byte[] bytes)
+ {
return bytes;
}
- protected byte[] toInternalFormat(Object bytes) {
+ protected byte[] toInternalFormat(Object bytes)
+ {
return ( byte[] ) bytes;
}
}
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/RepositoryEntry.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/RepositoryEntry.java 2009-01-13
20:50:30 UTC (rev 12490)
+++
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/RepositoryEntry.java 2009-01-13
21:34:32 UTC (rev 12491)
@@ -33,7 +33,7 @@
private Integer key;
private String path;
private String name;
- private byte[] data;
+ private java.sql.Blob data;
private long lastmod;
private long length;
@@ -41,7 +41,7 @@
{
}
- public RepositoryEntry(String path, String name, byte[] data, long lastmod, long
length)
+ public RepositoryEntry(String path, String name, java.sql.Blob data, long lastmod,
long length)
{
this.key = null;
this.path = path;
@@ -81,12 +81,12 @@
this.name = name;
}
- public byte[] getData()
+ public java.sql.Blob getData()
{
return data;
}
- public void setData(byte[] data)
+ public void setData(java.sql.Blob data)
{
this.data = data;
}
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/VersionEntry.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/VersionEntry.java 2009-01-13
20:50:30 UTC (rev 12490)
+++
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/VersionEntry.java 2009-01-13
21:34:32 UTC (rev 12491)
@@ -33,7 +33,7 @@
private Integer key;
private String path;
private String name;
- private byte[] data;
+ private java.sql.Blob data;
private long lastmod;
private long length;
@@ -41,7 +41,7 @@
{
}
- public VersionEntry(String path, String name, byte[] data, long lastmod, long length)
+ public VersionEntry(String path, String name, java.sql.Blob data, long lastmod, long
length)
{
this.key = null;
this.path = path;
@@ -81,12 +81,12 @@
this.name = name;
}
- public byte[] getData()
+ public java.sql.Blob getData()
{
return data;
}
- public void setData(byte[] data)
+ public void setData(java.sql.Blob data)
{
this.data = data;
}
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java 2009-01-13
20:50:30 UTC (rev 12490)
+++
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java 2009-01-13
21:34:32 UTC (rev 12491)
@@ -1456,16 +1456,18 @@
.list();
Iterator iter = rs.iterator();
+ /*InputStream is = null;
byte[] blob = (byte[])iter.next();
+ is = new ByteArrayInputStream(blob);*/
/**
* This needs to be done this way due to issues with a combination of
Postgresql driver handling blobs and Jackrabbit 1.4
*
* Its fine for: hsqldb, mysql5, and oracle10g
*/
- InputStream is = null;
-
- /*InputStream blobStream = blob.getBinaryStream();
+ InputStream is = null;
+ java.sql.Blob blob = (java.sql.Blob)iter.next();
+ InputStream blobStream = blob.getBinaryStream();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024]; //using a 1K buffer
int bytesRead = -1;
@@ -1473,12 +1475,10 @@
{
bos.write(buffer, 0, bytesRead);
bos.flush();
- }
+ }
+ try{blobStream.close();}catch(Exception e){}
+ is = new ByteArrayInputStream(bos.toByteArray());
- try{blobStream.close();}catch(Exception e){}*/
-
- is = new ByteArrayInputStream(blob);
-
return is;
}
catch (Exception e)
@@ -1524,7 +1524,10 @@
throw new Exception("No such Node: " + blobId);
}
versionNode.setId(blobId);
- versionNode.setData(IOTools.getBytes(in));
+
+ //versionNode.setData(IOTools.getBytes(in));
+ versionNode.setData(Hibernate.createBlob(in));
+ session.flush();
}
else if (schemaObjectPrefix
.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
@@ -1534,9 +1537,12 @@
if (wspNode == null)
{
throw new Exception("No such Node: " + blobId);
- }
+ }
wspNode.setId(blobId);
- wspNode.setData(IOTools.getBytes(in));
+
+ //wspNode.setData(IOTools.getBytes(in));
+ wspNode.setData(Hibernate.createBlob(in));
+ session.flush();
}
}
catch (Exception e)
@@ -1559,15 +1565,22 @@
if (schemaObjectPrefix
.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
{
+ //VersionBinVal versionNode = new VersionBinVal(blobId,
+ // IOTools.getBytes(in));
VersionBinVal versionNode = new VersionBinVal(blobId,
- IOTools.getBytes(in));
+ Hibernate.createBlob(in));
+
session.save(versionNode);
+ session.flush();
}
else if (schemaObjectPrefix
.equalsIgnoreCase(HibernateStoreConstants.wspPrefix))
{
- WSPBinVal wspNode = new WSPBinVal(blobId, IOTools.getBytes(in));
+ //WSPBinVal wspNode = new WSPBinVal(blobId, IOTools.getBytes(in));
+ WSPBinVal wspNode = new WSPBinVal(blobId, Hibernate.createBlob(in));
+
session.save(wspNode);
+ session.flush();
}
}
catch (Exception e)
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/VersionBinVal.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/VersionBinVal.java 2009-01-13
20:50:30 UTC (rev 12490)
+++
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/VersionBinVal.java 2009-01-13
21:34:32 UTC (rev 12491)
@@ -32,13 +32,13 @@
private Integer key;
private String id;
- private byte[] data;
+ private java.sql.Blob data;
public VersionBinVal()
{
}
- public VersionBinVal(String id, byte[] data)
+ public VersionBinVal(String id, java.sql.Blob data)
{
this.key = null;
this.id = id;
@@ -65,12 +65,12 @@
this.id = id;
}
- public byte[] getData()
+ public java.sql.Blob getData()
{
return data;
}
- public void setData(byte[] data)
+ public void setData(java.sql.Blob data)
{
this.data = data;
}
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/WSPBinVal.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/WSPBinVal.java 2009-01-13
20:50:30 UTC (rev 12490)
+++
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/WSPBinVal.java 2009-01-13
21:34:32 UTC (rev 12491)
@@ -32,13 +32,13 @@
private Integer key;
private String id;
- private byte[] data;
+ private java.sql.Blob data;
public WSPBinVal()
{
}
- public WSPBinVal(String id, byte[] data)
+ public WSPBinVal(String id, java.sql.Blob data)
{
this.key = null;
this.id = id;
@@ -65,12 +65,12 @@
this.id = id;
}
- public byte[] getData()
+ public java.sql.Blob getData()
{
return data;
}
- public void setData(byte[] data)
+ public void setData(java.sql.Blob data)
{
this.data = data;
}
Deleted:
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/blobs/TestBlobPortability.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/blobs/TestBlobPortability.java 2009-01-13
20:50:30 UTC (rev 12490)
+++
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/blobs/TestBlobPortability.java 2009-01-13
21:34:32 UTC (rev 12491)
@@ -1,84 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.portal.cms.test.blobs;
-
-import java.io.Serializable;
-import javax.naming.InitialContext;
-
-import org.apache.log4j.Logger;
-
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-
-import org.jboss.unit.api.pojo.annotations.Test;
-import org.jboss.unit.mc.api.annotations.Bootstrap;
-
-import org.jboss.portal.cms.test.AbstractCMSTestCase;
-
-/**
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- */
-@Bootstrap(beanName = "TestCase",
resourceName="/jboss-beans-blobs.xml")
-public class TestBlobPortability extends AbstractCMSTestCase
-{
- private static Logger log = Logger.getLogger(TestBlobPortability.class);
-
- @Test
- public void testCreateFile() throws Exception
- {
- Session session = null;
- Transaction tx = null;
- try
- {
- SessionFactory sessionFactory = (SessionFactory)new
InitialContext().lookup("java:/SessionFactory");
- session = sessionFactory.openSession();
- tx = session.beginTransaction();
-
- CMSFile cmsFile = new CMSFile();
- cmsFile.setName("testName");
- cmsFile.setContent("123456789".getBytes());
-
- Serializable uid = session.save(cmsFile);
-
- log.info("-------------------------------------------");
- log.info("New File Id="+uid);
-
- tx.commit();
- }
- catch(Exception e)
- {
- if(tx != null)
- {
- tx.rollback();
- }
- throw e;
- }
- finally
- {
- if(session != null)
- {
- session.close();
- }
- }
- }
-}
Modified:
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/blobs/TestBlobPortabilityTestCase.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/blobs/TestBlobPortabilityTestCase.java 2009-01-13
20:50:30 UTC (rev 12490)
+++
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/blobs/TestBlobPortabilityTestCase.java 2009-01-13
21:34:32 UTC (rev 12491)
@@ -23,8 +23,6 @@
import java.io.Serializable;
-import javax.naming.InitialContext;
-
import junit.framework.TestCase;
import org.hibernate.SessionFactory;
@@ -32,6 +30,11 @@
import org.hibernate.cfg.Configuration;
import org.hibernate.Transaction;
+import org.hibernate.dialect.PostgreSQLDialect;
+import org.hibernate.dialect.MySQL5InnoDBDialect;
+import org.hibernate.dialect.Oracle10gDialect;
+import org.hibernate.dialect.Oracle9iDialect;
+
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*/
@@ -52,6 +55,17 @@
public void testCreateFile() throws Exception
{
+ PostgreSQLDialect psqldialect = new PostgreSQLDialect();
+ Oracle9iDialect oracle9idialect = new Oracle9iDialect();
+ Oracle10gDialect oracle10gdialect = new Oracle10gDialect();
+ MySQL5InnoDBDialect mysqldialect = new MySQL5InnoDBDialect();
+ System.out.println("-----------------------------------------");
+ System.out.println("PostGres Proper LOB
Support="+psqldialect.supportsExpectedLobUsagePattern());
+ System.out.println("Oracle10g Proper LOB
Support="+oracle9idialect.supportsExpectedLobUsagePattern());
+ System.out.println("Oracle9i Proper LOB
Support="+oracle10gdialect.supportsExpectedLobUsagePattern());
+ System.out.println("Mysql Proper LOB
Support="+mysqldialect.supportsExpectedLobUsagePattern());
+ System.out.println("-----------------------------------------");
+
Session session = null;
Transaction tx = null;
try
@@ -64,6 +78,7 @@
tx = session.beginTransaction();
Serializable uid = session.save(cmsFile);
+ session.flush();
System.out.println("-------------------------------------------");
System.out.println("New File Id="+uid);
Modified: modules/cms/trunk/cms-jackrabbit/src/test/resources/blobs.hbm.xml
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/test/resources/blobs.hbm.xml 2009-01-13 20:50:30
UTC (rev 12490)
+++ modules/cms/trunk/cms-jackrabbit/src/test/resources/blobs.hbm.xml 2009-01-13 21:34:32
UTC (rev 12491)
@@ -42,9 +42,16 @@
<property
name="content"
column="content"
- type="binary"
+ type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
not-null="true"
- length="1000000000"
- />
+ />
+ <!--
+ <property
+ name="content"
+ column="content"
+ type="blob"
+ not-null="true"
+ />
+ -->
</class>
</hibernate-mapping>
\ No newline at end of file
Modified: modules/cms/trunk/cms-jackrabbit/src/test/resources/domain.hbm.xml
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/test/resources/domain.hbm.xml 2009-01-13 20:50:30
UTC (rev 12490)
+++ modules/cms/trunk/cms-jackrabbit/src/test/resources/domain.hbm.xml 2009-01-13 21:34:32
UTC (rev 12491)
@@ -41,7 +41,7 @@
<property
name="data"
column="BINVAL_DATA"
- type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
+ type="blob"
length="100000000"
not-null="true"/>
</class>
@@ -117,7 +117,7 @@
<property
name="data"
column="BINVAL_DATA"
- type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
+ type="blob"
length="100000000"
not-null="true"/>
</class>
@@ -198,7 +198,7 @@
length="245"/>
<property name="data"
column="FSENTRY_DATA"
- type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
+ type="blob"
length="100000000"
not-null="false"/>
<property name="lastmod"
@@ -230,7 +230,7 @@
length="245"/>
<property name="data"
column="FSENTRY_DATA"
- type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
+ type="blob"
length="100000000"
not-null="false"/>
<property name="lastmod"
@@ -262,7 +262,7 @@
length="245"/>
<property name="data"
column="FSENTRY_DATA"
- type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
+ type="blob"
length="100000000"
not-null="false"/>
<property name="lastmod"
Modified: modules/cms/trunk/cms-jackrabbit/src/test/resources/hibernate.cfg.xml
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/test/resources/hibernate.cfg.xml 2009-01-13
20:50:30 UTC (rev 12490)
+++ modules/cms/trunk/cms-jackrabbit/src/test/resources/hibernate.cfg.xml 2009-01-13
21:34:32 UTC (rev 12491)
@@ -14,22 +14,21 @@
<property
name="hibernate.connection.password">portalpassword</property>
-->
-
+ <!--
<property
name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property
name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
<property
name="hibernate.connection.username">portal</property>
<property
name="hibernate.connection.password">portalpassword</property>
+ -->
- <!--
<property
name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property
name="hibernate.connection.url">jdbc:postgresql:jbossportal</property>
<property
name="hibernate.connection.username">portal</property>
<property
name="hibernate.connection.password">portalpassword</property>
- -->
<!-- other hibernate properties -->
<property name="show_sql">true</property>
- <property name="hbm2ddl.auto">update</property>
+ <property name="hbm2ddl.auto">create-drop</property>
<mapping resource="blobs.hbm.xml"/>
Modified: modules/cms/trunk/cms-jackrabbit/src/test/resources/jboss-unit.xml
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/test/resources/jboss-unit.xml 2009-01-13 20:50:30
UTC (rev 12490)
+++ modules/cms/trunk/cms-jackrabbit/src/test/resources/jboss-unit.xml 2009-01-13 21:34:32
UTC (rev 12491)
@@ -5,18 +5,16 @@
xsi:schemaLocation="urn:jboss:jboss-unit:1.0 jboss-unit_1_0.xsd">
<pojo>
<parameter name="datasources" value="datasources.xml"/>
- <parameter name="dataSourceName">
- <value>hsqldb</value>
- <!--
+ <parameter name="dataSourceName">
+ <value>hsqldb</value>
<value>oracle10g</value>
- <value>mysql5</value>
+ <value>mysql5</value>
<value>postgresql8</value>
- -->
</parameter>
- <parameter name="hibernateConfig"
value="hibernates.xml"/>
+ <parameter name="hibernateConfig"
value="hibernates.xml"/>
<test >
<class
name="org.jboss.portal.cms.test.commands.TestFileArchiveUpload"/>
- </test>
+ </test>
<test >
<class name="org.jboss.portal.cms.test.commands.TestFileCopy"/>
</test>
@@ -79,12 +77,10 @@
<pojo>
<parameter name="datasources" value="datasources.xml"/>
<parameter name="dataSourceName">
- <value>hsqldb</value>
- <!--
+ <value>hsqldb</value>
<value>oracle10g</value>
<value>mysql5</value>
- <value>postgresql8</value>
- -->
+ <value>postgresql8</value>
</parameter>
<parameter name="hibernateConfig"
value="hibernates.xml"/>
<parameter name="standardIdentityConfig"
value="standardidentity-config.xml"/>
@@ -105,13 +101,11 @@
<pojo>
<parameter name="datasources" value="datasources.xml"/>
- <parameter name="dataSourceName">
+ <parameter name="dataSourceName">
<value>hsqldb</value>
- <!--
<value>oracle10g</value>
<value>mysql5</value>
<value>postgresql8</value>
- -->
</parameter>
<parameter name="hibernateConfig"
value="hibernates.xml"/>
<parameter name="standardIdentityConfig"
value="standardidentity-config.xml"/>
@@ -126,4 +120,4 @@
<class
name="org.jboss.portal.cms.test.workflow.TestWorkflowEnvironment"/>
</test>
</pojo>
-</jboss-unit>
+</jboss-unit>
\ No newline at end of file