HHH-5245 - Introduce LobHelper

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@19571 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2010-05-20 20:37:56 +00:00
parent d06e11092d
commit 5aa6ad61ca
7 changed files with 87 additions and 26 deletions

View File

@ -46,7 +46,7 @@ public interface JdbcSupport {
public LobCreator getLobCreator();
/**
* Create an instance of a {@link LobCreator} appropriate for the current envionment, mainly meant to account for
* Create an instance of a {@link LobCreator} appropriate for the current environment, mainly meant to account for
* variance between JDBC 4 (<= JDK 1.6) and JDBC3 (>= JDK 1.5).
*
* @param lobCreationContext The context in which the LOB is being created

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.dialect.functional.cache;
import java.sql.Statement;
@ -510,8 +533,8 @@ public class SQLFunctionsInterSystemsTest extends DatabaseSpecificFunctionalTest
Session s = openSession();
s.beginTransaction();
Blobber b = new Blobber();
b.setBlob( Hibernate.createBlob( "foo/bar/baz".getBytes() ) );
b.setClob( Hibernate.createClob("foo/bar/baz") );
b.setBlob( s.getLobHelper().createBlob( "foo/bar/baz".getBytes() ) );
b.setClob( s.getLobHelper().createClob("foo/bar/baz") );
s.save(b);
//s.refresh(b);
//assertTrue( b.getClob() instanceof ClobImpl );
@ -542,7 +565,7 @@ public class SQLFunctionsInterSystemsTest extends DatabaseSpecificFunctionalTest
s = openSession();
s.beginTransaction();
b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) );
b.setClob( Hibernate.createClob("xcvfxvc xcvbx cvbx cvbx cvbxcvbxcvbxcvb") );
b.setClob( s.getLobHelper().createClob("xcvfxvc xcvbx cvbx cvbx cvbxcvbxcvbxcvb") );
s.flush();
s.getTransaction().commit();
s.close();

View File

@ -3,7 +3,6 @@ package org.hibernate.test.interfaceproxy;
import junit.framework.Test;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.junit.functional.FunctionalTestCase;
@ -41,11 +40,11 @@ public class InterfaceProxyTest extends FunctionalTestCase {
Transaction t = s.beginTransaction();
Document d = new DocumentImpl();
d.setName("Hibernate in Action");
d.setContent( Hibernate.createBlob( "blah blah blah".getBytes(), s ) );
d.setContent( s.getLobHelper().createBlob( "blah blah blah".getBytes() ) );
Long did = (Long) s.save(d);
SecureDocument d2 = new SecureDocumentImpl();
d2.setName("Secret");
d2.setContent( Hibernate.createBlob( "wxyz wxyz".getBytes(), s ) );
d2.setContent( s.getLobHelper().createBlob( "wxyz wxyz".getBytes() ) );
// SybaseASE15Dialect only allows 7-bits in a byte to be inserted into a tinyint
// column (0 <= val < 128)
d2.setPermissionBits( (byte) 127 );

View File

@ -1,4 +1,26 @@
//$Id: SQLFunctionsTest.java 10977 2006-12-12 23:28:04Z steve.ebersole@jboss.com $
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.legacy;
import java.util.ArrayList;
@ -13,7 +35,6 @@ import junit.framework.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.hibernate.Hibernate;
import org.hibernate.Query;
import org.hibernate.ScrollableResults;
import org.hibernate.Transaction;
@ -519,8 +540,8 @@ public class SQLFunctionsTest extends LegacyTestCase {
Session s = openSession();
Blobber b = new Blobber();
b.setBlob( Hibernate.createBlob( "foo/bar/baz".getBytes() ) );
b.setClob( Hibernate.createClob("foo/bar/baz") );
b.setBlob( s.getLobHelper().createBlob( "foo/bar/baz".getBytes() ) );
b.setClob( s.getLobHelper().createClob("foo/bar/baz") );
s.save(b);
//s.refresh(b);
//assertTrue( b.getClob() instanceof ClobImpl );
@ -556,7 +577,7 @@ public class SQLFunctionsTest extends LegacyTestCase {
s = openSession();
b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) );
b.setClob( Hibernate.createClob("xcvfxvc xcvbx cvbx cvbx cvbxcvbxcvbxcvb") );
b.setClob( s.getLobHelper().createClob("xcvfxvc xcvbx cvbx cvbx cvbxcvbxcvbxcvb") );
s.flush();
s.connection().commit();
s.close();

View File

@ -75,7 +75,7 @@ public class BlobLocatorTest extends DatabaseSpecificFunctionalTestCase {
Session s = openSession();
s.beginTransaction();
LobHolder entity = new LobHolder();
entity.setBlobLocator( Hibernate.createBlob( original ) );
entity.setBlobLocator( s.getLobHelper().createBlob( original ) );
s.save( entity );
s.getTransaction().commit();
s.close();
@ -117,7 +117,7 @@ public class BlobLocatorTest extends DatabaseSpecificFunctionalTestCase {
assertNotNull( entity.getBlobLocator() );
assertEquals( BLOB_SIZE, entity.getBlobLocator().length() );
assertEquals( original, extractData( entity.getBlobLocator() ) );
entity.setBlobLocator( Hibernate.createBlob( changed ) );
entity.setBlobLocator( s.getLobHelper().createBlob( changed ) );
s.getTransaction().commit();
s.close();

View File

@ -1,11 +1,10 @@
//$Id: $
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@ -21,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*
*/
package org.hibernate.test.lob;
@ -29,7 +27,6 @@ import java.sql.Clob;
import junit.framework.Test;
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
import org.hibernate.Session;
import org.hibernate.dialect.Dialect;
@ -74,7 +71,7 @@ public class ClobLocatorTest extends DatabaseSpecificFunctionalTestCase {
Session s = openSession();
s.beginTransaction();
LobHolder entity = new LobHolder();
entity.setClobLocator( Hibernate.createClob( original ) );
entity.setClobLocator( s.getLobHelper().createClob( original ) );
s.save( entity );
s.getTransaction().commit();
s.close();
@ -116,7 +113,7 @@ public class ClobLocatorTest extends DatabaseSpecificFunctionalTestCase {
assertNotNull( entity.getClobLocator() );
assertEquals( CLOB_SIZE, entity.getClobLocator().length() );
assertEquals( original, extractData( entity.getClobLocator() ) );
entity.setClobLocator( Hibernate.createClob( changed ) );
entity.setClobLocator( s.getLobHelper().createClob( changed ) );
s.getTransaction().commit();
s.close();
@ -145,7 +142,7 @@ public class ClobLocatorTest extends DatabaseSpecificFunctionalTestCase {
Session s = openSession();
s.beginTransaction();
LobHolder entity = new LobHolder();
entity.setClobLocator( Hibernate.createClob( original ) );
entity.setClobLocator( s.getLobHelper().createClob( original ) );
s.save( entity );
s.getTransaction().commit();
s.close();

View File

@ -1,9 +1,30 @@
//$Id: MixedTest.java 15736 2008-12-27 00:49:42Z gbadner $
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.mixed;
import junit.framework.Test;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.junit.functional.FunctionalTestCase;
@ -39,13 +60,13 @@ public class MixedTest extends FunctionalTestCase {
Document d = new Document();
d.setName( "Hibernate in Action" );
d.setContent( Hibernate.createBlob( "blah blah blah".getBytes() ) );
d.setContent( s.getLobHelper().createBlob( "blah blah blah".getBytes() ) );
d.setParent( f );
Long did = (Long) s.save( d );
SecureDocument d2 = new SecureDocument();
d2.setName( "Secret" );
d2.setContent( Hibernate.createBlob( "wxyz wxyz".getBytes() ) );
d2.setContent( s.getLobHelper().createBlob( "wxyz wxyz".getBytes() ) );
// SybaseASE15Dialect only allows 7-bits in a byte to be inserted into a tinyint
// column (0 <= val < 128)
d2.setPermissionBits( (byte) 127 );