HHH-7484 Removing obsolete //$Id$ and adding missing license headers (no functional changes)

This commit is contained in:
Hardy Ferentschik 2012-07-31 14:33:53 +02:00
parent 7f3ad01b50
commit 672368931f
22 changed files with 242 additions and 119 deletions

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.test.annotations.lob; package org.hibernate.test.annotations.lob;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.test.annotations.lob; package org.hibernate.test.annotations.lob;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;

View File

@ -45,7 +45,7 @@ public abstract class AbstractLobTest<B extends AbstractBook, C extends Abstract
try { try {
return getBookClass().newInstance(); return getBookClass().newInstance();
} }
catch (Exception ex) { catch ( Exception ex ) {
throw new RuntimeException( "Could not create an instance of type " + getBookClass().getName(), ex ); throw new RuntimeException( "Could not create an instance of type " + getBookClass().getName(), ex );
} }
} }
@ -58,8 +58,11 @@ public abstract class AbstractLobTest<B extends AbstractBook, C extends Abstract
try { try {
return getCompiledCodeClass().newInstance(); return getCompiledCodeClass().newInstance();
} }
catch (Exception ex) { catch ( Exception ex ) {
throw new RuntimeException( "Could not create an instance of type " + getCompiledCodeClass().getName(), ex ); throw new RuntimeException(
"Could not create an instance of type " + getCompiledCodeClass().getName(),
ex
);
} }
} }

View File

@ -1,5 +1,29 @@
//$Id$ /*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2009, Red Hat Middleware LLC 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.
*
* 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.annotations.lob; package org.hibernate.test.annotations.lob;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;

View File

@ -1,4 +1,3 @@
//$Id: $
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
@ -24,13 +23,14 @@
* *
*/ */
package org.hibernate.test.annotations.lob; package org.hibernate.test.annotations.lob;
import org.hibernate.type.AbstractSingleColumnStandardBasicType; import org.hibernate.type.AbstractSingleColumnStandardBasicType;
import org.hibernate.type.descriptor.java.CharacterArrayTypeDescriptor; import org.hibernate.type.descriptor.java.CharacterArrayTypeDescriptor;
import org.hibernate.type.descriptor.sql.LongVarcharTypeDescriptor; import org.hibernate.type.descriptor.sql.LongVarcharTypeDescriptor;
/** /**
* A type that maps JDBC {@link java.sql.Types#LONGVARCHAR LONGVARCHAR} and {@code Character[]}. * A type that maps JDBC {@link java.sql.Types#LONGVARCHAR LONGVARCHAR} and {@code Character[]}.
* *
* @author Strong Liu * @author Strong Liu
*/ */
public class CharacterArrayTextType extends AbstractSingleColumnStandardBasicType<Character[]> { public class CharacterArrayTextType extends AbstractSingleColumnStandardBasicType<Character[]> {

View File

@ -1,5 +1,29 @@
//$Id$ /*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC 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.
*
* 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.annotations.lob; package org.hibernate.test.annotations.lob;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;

View File

@ -1,4 +1,29 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC 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.
*
* 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.annotations.lob; package org.hibernate.test.annotations.lob;
import java.io.Serializable; import java.io.Serializable;
public class Dog implements Serializable { public class Dog implements Serializable {

View File

@ -1,5 +1,29 @@
//$Id$ /*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC 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.
*
* 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.annotations.lob; package org.hibernate.test.annotations.lob;
import java.io.Serializable; import java.io.Serializable;
/** /**

View File

@ -1,4 +1,3 @@
//$Id: $
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
@ -24,6 +23,7 @@
* *
*/ */
package org.hibernate.test.annotations.lob; package org.hibernate.test.annotations.lob;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
@ -31,8 +31,8 @@ import javax.persistence.Id;
/** /**
* An entity containing data that is materialized into a byte array immediately. * An entity containing data that is materialized into a byte array immediately.
* The hibernate type mapped for {@link #longByteArray} determines the SQL type * The hibernate type mapped for {@link #longByteArray} determines the SQL type
* asctually used. * actually used.
* *
* @author Gail Badner * @author Gail Badner
*/ */
@Entity @Entity
@ -51,8 +51,8 @@ public class ImageHolder {
public void setId(Long id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
@org.hibernate.annotations.Type(type="image") @org.hibernate.annotations.Type(type = "image")
public byte[] getLongByteArray() { public byte[] getLongByteArray() {
return longByteArray; return longByteArray;
} }
@ -60,7 +60,8 @@ public class ImageHolder {
public void setLongByteArray(byte[] longByteArray) { public void setLongByteArray(byte[] longByteArray) {
this.longByteArray = longByteArray; this.longByteArray = longByteArray;
} }
@org.hibernate.annotations.Type(type="serializable_image")
@org.hibernate.annotations.Type(type = "serializable_image")
public Dog getDog() { public Dog getDog() {
return dog; return dog;
} }
@ -68,7 +69,8 @@ public class ImageHolder {
public void setDog(Dog dog) { public void setDog(Dog dog) {
this.dog = dog; this.dog = dog;
} }
@org.hibernate.annotations.Type(type="wrapped_image")
@org.hibernate.annotations.Type(type = "wrapped_image")
public Byte[] getPicByteArray() { public Byte[] getPicByteArray() {
return picByteArray; return picByteArray;
} }

View File

@ -42,74 +42,74 @@ import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
* *
* @author Gail Badner * @author Gail Badner
*/ */
@RequiresDialect( { SybaseASE15Dialect.class, SQLServerDialect.class, SybaseDialect.class, Sybase11Dialect.class }) @RequiresDialect({ SybaseASE15Dialect.class, SQLServerDialect.class, SybaseDialect.class, Sybase11Dialect.class })
public class ImageTest extends BaseCoreFunctionalTestCase { public class ImageTest extends BaseCoreFunctionalTestCase {
private static final int ARRAY_SIZE = 10000; private static final int ARRAY_SIZE = 10000;
@Test @Test
public void testBoundedLongByteArrayAccess() { public void testBoundedLongByteArrayAccess() {
byte[] original = buildRecursively(ARRAY_SIZE, true); byte[] original = buildRecursively( ARRAY_SIZE, true );
byte[] changed = buildRecursively(ARRAY_SIZE, false); byte[] changed = buildRecursively( ARRAY_SIZE, false );
Session s = openSession(); Session s = openSession();
s.beginTransaction(); s.beginTransaction();
ImageHolder entity = new ImageHolder(); ImageHolder entity = new ImageHolder();
s.save(entity); s.save( entity );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
s = openSession(); s = openSession();
s.beginTransaction(); s.beginTransaction();
entity = (ImageHolder) s.get(ImageHolder.class, entity.getId()); entity = ( ImageHolder ) s.get( ImageHolder.class, entity.getId() );
Assert.assertNull( entity.getLongByteArray() ); Assert.assertNull( entity.getLongByteArray() );
Assert.assertNull( entity.getDog() ); Assert.assertNull( entity.getDog() );
Assert.assertNull( entity.getPicByteArray() ); Assert.assertNull( entity.getPicByteArray() );
entity.setLongByteArray(original); entity.setLongByteArray( original );
Dog dog = new Dog(); Dog dog = new Dog();
dog.setName("rabbit"); dog.setName( "rabbit" );
entity.setDog(dog); entity.setDog( dog );
entity.setPicByteArray(wrapPrimitive(original)); entity.setPicByteArray( wrapPrimitive( original ) );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
s = openSession(); s = openSession();
s.beginTransaction(); s.beginTransaction();
entity = (ImageHolder) s.get(ImageHolder.class, entity.getId()); entity = ( ImageHolder ) s.get( ImageHolder.class, entity.getId() );
Assert.assertEquals( ARRAY_SIZE, entity.getLongByteArray().length ); Assert.assertEquals( ARRAY_SIZE, entity.getLongByteArray().length );
assertEquals(original, entity.getLongByteArray()); assertEquals( original, entity.getLongByteArray() );
Assert.assertEquals( ARRAY_SIZE, entity.getPicByteArray().length ); Assert.assertEquals( ARRAY_SIZE, entity.getPicByteArray().length );
assertEquals(original, unwrapNonPrimitive(entity.getPicByteArray())); assertEquals( original, unwrapNonPrimitive( entity.getPicByteArray() ) );
Assert.assertNotNull( entity.getDog() ); Assert.assertNotNull( entity.getDog() );
Assert.assertEquals( dog.getName(), entity.getDog().getName() ); Assert.assertEquals( dog.getName(), entity.getDog().getName() );
entity.setLongByteArray(changed); entity.setLongByteArray( changed );
entity.setPicByteArray(wrapPrimitive(changed)); entity.setPicByteArray( wrapPrimitive( changed ) );
dog.setName("papa"); dog.setName( "papa" );
entity.setDog(dog); entity.setDog( dog );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
s = openSession(); s = openSession();
s.beginTransaction(); s.beginTransaction();
entity = (ImageHolder) s.get(ImageHolder.class, entity.getId()); entity = ( ImageHolder ) s.get( ImageHolder.class, entity.getId() );
Assert.assertEquals( ARRAY_SIZE, entity.getLongByteArray().length ); Assert.assertEquals( ARRAY_SIZE, entity.getLongByteArray().length );
assertEquals(changed, entity.getLongByteArray()); assertEquals( changed, entity.getLongByteArray() );
Assert.assertEquals( ARRAY_SIZE, entity.getPicByteArray().length ); Assert.assertEquals( ARRAY_SIZE, entity.getPicByteArray().length );
assertEquals(changed, unwrapNonPrimitive(entity.getPicByteArray())); assertEquals( changed, unwrapNonPrimitive( entity.getPicByteArray() ) );
Assert.assertNotNull( entity.getDog() ); Assert.assertNotNull( entity.getDog() );
Assert.assertEquals( dog.getName(), entity.getDog().getName() ); Assert.assertEquals( dog.getName(), entity.getDog().getName() );
entity.setLongByteArray(null); entity.setLongByteArray( null );
entity.setPicByteArray(null); entity.setPicByteArray( null );
entity.setDog(null); entity.setDog( null );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
s = openSession(); s = openSession();
s.beginTransaction(); s.beginTransaction();
entity = (ImageHolder) s.get(ImageHolder.class, entity.getId()); entity = ( ImageHolder ) s.get( ImageHolder.class, entity.getId() );
Assert.assertNull( entity.getLongByteArray() ); Assert.assertNull( entity.getLongByteArray() );
Assert.assertNull( entity.getDog() ); Assert.assertNull( entity.getDog() );
Assert.assertNull( entity.getPicByteArray() ); Assert.assertNull( entity.getPicByteArray() );
s.delete(entity); s.delete( entity );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
} }
@ -117,7 +117,7 @@ public class ImageTest extends BaseCoreFunctionalTestCase {
private Byte[] wrapPrimitive(byte[] bytes) { private Byte[] wrapPrimitive(byte[] bytes) {
int length = bytes.length; int length = bytes.length;
Byte[] result = new Byte[length]; Byte[] result = new Byte[length];
for (int index = 0; index < length; index++) { for ( int index = 0; index < length; index++ ) {
result[index] = Byte.valueOf( bytes[index] ); result[index] = Byte.valueOf( bytes[index] );
} }
return result; return result;
@ -126,7 +126,7 @@ public class ImageTest extends BaseCoreFunctionalTestCase {
private byte[] unwrapNonPrimitive(Byte[] bytes) { private byte[] unwrapNonPrimitive(Byte[] bytes) {
int length = bytes.length; int length = bytes.length;
byte[] result = new byte[length]; byte[] result = new byte[length];
for (int i = 0; i < length; i++) { for ( int i = 0; i < length; i++ ) {
result[i] = bytes[i].byteValue(); result[i] = bytes[i].byteValue();
} }
return result; return result;
@ -134,21 +134,21 @@ public class ImageTest extends BaseCoreFunctionalTestCase {
private byte[] buildRecursively(int size, boolean on) { private byte[] buildRecursively(int size, boolean on) {
byte[] data = new byte[size]; byte[] data = new byte[size];
data[0] = mask(on); data[0] = mask( on );
for (int i = 0; i < size; i++) { for ( int i = 0; i < size; i++ ) {
data[i] = mask(on); data[i] = mask( on );
on = !on; on = !on;
} }
return data; return data;
} }
private byte mask(boolean on) { private byte mask(boolean on) {
return on ? (byte) 1 : (byte) 0; return on ? ( byte ) 1 : ( byte ) 0;
} }
public static void assertEquals(byte[] val1, byte[] val2) { public static void assertEquals(byte[] val1, byte[] val2) {
if (!ArrayHelper.isEquals( val1, val2 )) { if ( !ArrayHelper.isEquals( val1, val2 ) ) {
throw new AssertionFailedError("byte arrays did not match"); throw new AssertionFailedError( "byte arrays did not match" );
} }
} }
@ -158,7 +158,7 @@ public class ImageTest extends BaseCoreFunctionalTestCase {
} }
@Override @Override
public Class<?>[] getAnnotatedClasses() { public Class<?>[] getAnnotatedClasses() {
return new Class[] { ImageHolder.class }; return new Class[] { ImageHolder.class };
} }

View File

@ -1,8 +1,7 @@
//$Id$
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as * Copyright (c) 2008, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution * indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are * statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc. * distributed under license by Red Hat Inc.
@ -25,14 +24,12 @@
package org.hibernate.test.annotations.lob; package org.hibernate.test.annotations.lob;
import org.hibernate.testing.DialectChecks; import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.RequiresDialectFeature;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
@RequiresDialectFeature(DialectChecks.SupportsExpectedLobUsagePattern.class) @RequiresDialectFeature(DialectChecks.SupportsExpectedLobUsagePattern.class)
@FailureExpectedWithNewMetamodel
public class LobTest extends AbstractLobTest<Book, CompiledCode> { public class LobTest extends AbstractLobTest<Book, CompiledCode> {
@Override @Override
protected Class<Book> getBookClass() { protected Class<Book> getBookClass() {

View File

@ -1,4 +1,3 @@
//$Id: $
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
@ -24,6 +23,7 @@
* *
*/ */
package org.hibernate.test.annotations.lob; package org.hibernate.test.annotations.lob;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
@ -34,7 +34,7 @@ import org.hibernate.annotations.Type;
* An entity containing data that is materialized into a String immediately. * An entity containing data that is materialized into a String immediately.
* The hibernate type mapped for {@link #LONGVARCHAR} determines the SQL type * The hibernate type mapped for {@link #LONGVARCHAR} determines the SQL type
* asctually used. * asctually used.
* *
* @author Gail Badner * @author Gail Badner
*/ */
@Entity @Entity
@ -62,6 +62,7 @@ public class LongStringHolder {
public void setLongString(String longString) { public void setLongString(String longString) {
this.longString = longString; this.longString = longString;
} }
@Type(type = "char_text") @Type(type = "char_text")
public char[] getName() { public char[] getName() {
return name; return name;
@ -70,6 +71,7 @@ public class LongStringHolder {
public void setName(char[] name) { public void setName(char[] name) {
this.name = name; this.name = name;
} }
@Type(type = "wrapped_char_text") @Type(type = "wrapped_char_text")
public Character[] getWhatEver() { public Character[] getWhatEver() {
return whatEver; return whatEver;

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.test.annotations.lob; package org.hibernate.test.annotations.lob;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;

View File

@ -51,8 +51,12 @@ public class MaterializedBlobTest extends BaseCoreFunctionalTestCase {
@Test @Test
public void testTypeSelection() { public void testTypeSelection() {
int index = sessionFactory().getEntityPersister( MaterializedBlobEntity.class.getName() ).getEntityMetamodel().getPropertyIndex( "theBytes" ); int index = sessionFactory().getEntityPersister( MaterializedBlobEntity.class.getName() )
Type type = sessionFactory().getEntityPersister( MaterializedBlobEntity.class.getName() ).getEntityMetamodel().getProperties()[index].getType(); .getEntityMetamodel()
.getPropertyIndex( "theBytes" );
Type type = sessionFactory().getEntityPersister( MaterializedBlobEntity.class.getName() )
.getEntityMetamodel()
.getProperties()[index].getType();
assertEquals( MaterializedBlobType.INSTANCE, type ); assertEquals( MaterializedBlobType.INSTANCE, type );
} }

View File

@ -1,4 +1,3 @@
//$Id: $
/* /*
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
@ -24,13 +23,14 @@
* *
*/ */
package org.hibernate.test.annotations.lob; package org.hibernate.test.annotations.lob;
import org.hibernate.type.AbstractSingleColumnStandardBasicType; import org.hibernate.type.AbstractSingleColumnStandardBasicType;
import org.hibernate.type.descriptor.java.PrimitiveCharacterArrayTypeDescriptor; import org.hibernate.type.descriptor.java.PrimitiveCharacterArrayTypeDescriptor;
import org.hibernate.type.descriptor.sql.LongVarcharTypeDescriptor; import org.hibernate.type.descriptor.sql.LongVarcharTypeDescriptor;
/** /**
* A type that maps JDBC {@link java.sql.Types#LONGVARCHAR LONGVARCHAR} and {@code char[]}. * A type that maps JDBC {@link java.sql.Types#LONGVARCHAR LONGVARCHAR} and {@code char[]}.
* *
* @author Strong Liu * @author Strong Liu
*/ */
public class PrimitiveCharacterArrayTextType extends AbstractSingleColumnStandardBasicType<char[]> { public class PrimitiveCharacterArrayTextType extends AbstractSingleColumnStandardBasicType<char[]> {

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.test.annotations.lob; package org.hibernate.test.annotations.lob;
import java.io.Serializable; import java.io.Serializable;
import org.hibernate.type.AbstractSingleColumnStandardBasicType; import org.hibernate.type.AbstractSingleColumnStandardBasicType;
@ -32,14 +33,17 @@ import org.hibernate.type.descriptor.sql.LongVarbinaryTypeDescriptor;
* A type that maps JDBC {@link java.sql.Types#LONGVARBINARY LONGVARBINARY} and {@link Serializable}. * A type that maps JDBC {@link java.sql.Types#LONGVARBINARY LONGVARBINARY} and {@link Serializable}.
* </p> * </p>
* TODO : this should really have access to the actual Serializable class so we have access to the proper classloader * TODO : this should really have access to the actual Serializable class so we have access to the proper classloader
* *
* @author Strong Liu * @author Strong Liu
*/ */
public class SerializableToImageType extends AbstractSingleColumnStandardBasicType<Serializable> { public class SerializableToImageType extends AbstractSingleColumnStandardBasicType<Serializable> {
public static final PrimitiveCharacterArrayTextType INSTANCE = new PrimitiveCharacterArrayTextType(); public static final PrimitiveCharacterArrayTextType INSTANCE = new PrimitiveCharacterArrayTextType();
public SerializableToImageType() { public SerializableToImageType() {
super( LongVarbinaryTypeDescriptor.INSTANCE, new SerializableTypeDescriptor<Serializable>( Serializable.class ) ); super(
LongVarbinaryTypeDescriptor.INSTANCE,
new SerializableTypeDescriptor<Serializable>( Serializable.class )
);
} }
public String getName() { public String getName() {

View File

@ -43,7 +43,7 @@ import static org.junit.Assert.assertNull;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@RequiresDialect({SybaseASE15Dialect.class,SQLServerDialect.class,SybaseDialect.class,Sybase11Dialect.class}) @RequiresDialect({ SybaseASE15Dialect.class, SQLServerDialect.class, SybaseDialect.class, Sybase11Dialect.class })
public class TextTest extends BaseCoreFunctionalTestCase { public class TextTest extends BaseCoreFunctionalTestCase {
@Override @Override
@ -55,33 +55,37 @@ public class TextTest extends BaseCoreFunctionalTestCase {
@Test @Test
public void testBoundedLongStringAccess() { public void testBoundedLongStringAccess() {
String original = buildRecursively(LONG_STRING_SIZE, 'x'); String original = buildRecursively( LONG_STRING_SIZE, 'x' );
String changed = buildRecursively(LONG_STRING_SIZE, 'y'); String changed = buildRecursively( LONG_STRING_SIZE, 'y' );
Session s = openSession(); Session s = openSession();
s.beginTransaction(); s.beginTransaction();
LongStringHolder entity = new LongStringHolder(); LongStringHolder entity = new LongStringHolder();
s.save(entity); s.save( entity );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
s = openSession(); s = openSession();
s.beginTransaction(); s.beginTransaction();
entity = (LongStringHolder) s.get(LongStringHolder.class, entity entity = ( LongStringHolder ) s.get(
.getId()); LongStringHolder.class, entity
assertNull(entity.getLongString()); .getId()
assertNull(entity.getName()); );
assertNull(entity.getWhatEver()); assertNull( entity.getLongString() );
entity.setLongString(original); assertNull( entity.getName() );
entity.setName(original.toCharArray()); assertNull( entity.getWhatEver() );
entity.setWhatEver(wrapPrimitive(original.toCharArray())); entity.setLongString( original );
entity.setName( original.toCharArray() );
entity.setWhatEver( wrapPrimitive( original.toCharArray() ) );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
s = openSession(); s = openSession();
s.beginTransaction(); s.beginTransaction();
entity = (LongStringHolder) s.get(LongStringHolder.class, entity entity = ( LongStringHolder ) s.get(
.getId()); LongStringHolder.class, entity
.getId()
);
Assert.assertEquals( LONG_STRING_SIZE, entity.getLongString().length() ); Assert.assertEquals( LONG_STRING_SIZE, entity.getLongString().length() );
Assert.assertEquals( original, entity.getLongString() ); Assert.assertEquals( original, entity.getLongString() );
Assert.assertNotNull( entity.getName() ); Assert.assertNotNull( entity.getName() );
@ -90,16 +94,18 @@ public class TextTest extends BaseCoreFunctionalTestCase {
Assert.assertNotNull( entity.getWhatEver() ); Assert.assertNotNull( entity.getWhatEver() );
Assert.assertEquals( LONG_STRING_SIZE, entity.getWhatEver().length ); Assert.assertEquals( LONG_STRING_SIZE, entity.getWhatEver().length );
assertEquals( original.toCharArray(), unwrapNonPrimitive( entity.getWhatEver() ) ); assertEquals( original.toCharArray(), unwrapNonPrimitive( entity.getWhatEver() ) );
entity.setLongString(changed); entity.setLongString( changed );
entity.setName(changed.toCharArray()); entity.setName( changed.toCharArray() );
entity.setWhatEver(wrapPrimitive(changed.toCharArray())); entity.setWhatEver( wrapPrimitive( changed.toCharArray() ) );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
s = openSession(); s = openSession();
s.beginTransaction(); s.beginTransaction();
entity = (LongStringHolder) s.get(LongStringHolder.class, entity entity = ( LongStringHolder ) s.get(
.getId()); LongStringHolder.class, entity
.getId()
);
Assert.assertEquals( LONG_STRING_SIZE, entity.getLongString().length() ); Assert.assertEquals( LONG_STRING_SIZE, entity.getLongString().length() );
Assert.assertEquals( changed, entity.getLongString() ); Assert.assertEquals( changed, entity.getLongString() );
Assert.assertNotNull( entity.getName() ); Assert.assertNotNull( entity.getName() );
@ -108,34 +114,36 @@ public class TextTest extends BaseCoreFunctionalTestCase {
Assert.assertNotNull( entity.getWhatEver() ); Assert.assertNotNull( entity.getWhatEver() );
Assert.assertEquals( LONG_STRING_SIZE, entity.getWhatEver().length ); Assert.assertEquals( LONG_STRING_SIZE, entity.getWhatEver().length );
assertEquals( changed.toCharArray(), unwrapNonPrimitive( entity.getWhatEver() ) ); assertEquals( changed.toCharArray(), unwrapNonPrimitive( entity.getWhatEver() ) );
entity.setLongString(null); entity.setLongString( null );
entity.setName(null); entity.setName( null );
entity.setWhatEver(null); entity.setWhatEver( null );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
s = openSession(); s = openSession();
s.beginTransaction(); s.beginTransaction();
entity = (LongStringHolder) s.get(LongStringHolder.class, entity entity = ( LongStringHolder ) s.get(
.getId()); LongStringHolder.class, entity
assertNull(entity.getLongString()); .getId()
assertNull(entity.getName()); );
assertNull(entity.getWhatEver()); assertNull( entity.getLongString() );
s.delete(entity); assertNull( entity.getName() );
assertNull( entity.getWhatEver() );
s.delete( entity );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
} }
public static void assertEquals(char[] val1, char[] val2) { public static void assertEquals(char[] val1, char[] val2) {
if (!ArrayHelper.isEquals( val1, val2 )) { if ( !ArrayHelper.isEquals( val1, val2 ) ) {
throw new AssertionFailedError("byte arrays did not match"); throw new AssertionFailedError( "byte arrays did not match" );
} }
} }
private String buildRecursively(int size, char baseChar) { private String buildRecursively(int size, char baseChar) {
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
for (int i = 0; i < size; i++) { for ( int i = 0; i < size; i++ ) {
buff.append(baseChar); buff.append( baseChar );
} }
return buff.toString(); return buff.toString();
} }
@ -143,8 +151,8 @@ public class TextTest extends BaseCoreFunctionalTestCase {
private Character[] wrapPrimitive(char[] bytes) { private Character[] wrapPrimitive(char[] bytes) {
int length = bytes.length; int length = bytes.length;
Character[] result = new Character[length]; Character[] result = new Character[length];
for (int index = 0; index < length; index++) { for ( int index = 0; index < length; index++ ) {
result[index] = Character.valueOf(bytes[index]); result[index] = Character.valueOf( bytes[index] );
} }
return result; return result;
} }
@ -152,7 +160,7 @@ public class TextTest extends BaseCoreFunctionalTestCase {
private char[] unwrapNonPrimitive(Character[] bytes) { private char[] unwrapNonPrimitive(Character[] bytes) {
int length = bytes.length; int length = bytes.length;
char[] result = new char[length]; char[] result = new char[length];
for (int i = 0; i < length; i++) { for ( int i = 0; i < length; i++ ) {
result[i] = bytes[i].charValue(); result[i] = bytes[i].charValue();
} }
return result; return result;

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.test.annotations.lob; package org.hibernate.test.annotations.lob;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
@ -34,10 +35,10 @@ import javax.persistence.Version;
*/ */
@Entity @Entity
@Table(name = "ver_lob_book") @Table(name = "ver_lob_book")
public class VersionedBook extends AbstractBook{ public class VersionedBook extends AbstractBook {
private Integer id; private Integer id;
private Integer version; private Integer version;
@Id @Id
@GeneratedValue @GeneratedValue
public Integer getId() { public Integer getId() {
@ -56,5 +57,5 @@ public class VersionedBook extends AbstractBook{
public void setVersion(Integer i) { public void setVersion(Integer i) {
version = i; version = i;
} }
} }

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.test.annotations.lob; package org.hibernate.test.annotations.lob;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
@ -34,7 +35,7 @@ import javax.persistence.Version;
* @author Gail Badner * @author Gail Badner
*/ */
@Entity @Entity
public class VersionedCompiledCode extends AbstractCompiledCode{ public class VersionedCompiledCode extends AbstractCompiledCode {
private Integer id; private Integer id;
private Integer version; private Integer version;

View File

@ -148,7 +148,7 @@ public class VersionedLobTest extends AbstractLobTest<VersionedBook, VersionedCo
} }
@Test @Test
@FailureExpected( jiraKey = "HHH-5811") @FailureExpected(jiraKey = "HHH-5811")
public void testVersionUnchangedByteArray() throws Exception { public void testVersionUnchangedByteArray() throws Exception {
Session s; Session s;
Transaction tx; Transaction tx;

View File

@ -22,13 +22,14 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.test.annotations.lob; package org.hibernate.test.annotations.lob;
import org.hibernate.type.AbstractSingleColumnStandardBasicType; import org.hibernate.type.AbstractSingleColumnStandardBasicType;
import org.hibernate.type.descriptor.java.ByteArrayTypeDescriptor; import org.hibernate.type.descriptor.java.ByteArrayTypeDescriptor;
import org.hibernate.type.descriptor.sql.LongVarbinaryTypeDescriptor; import org.hibernate.type.descriptor.sql.LongVarbinaryTypeDescriptor;
/** /**
* A type that maps JDBC {@link java.sql.Types#LONGVARBINARY LONGVARBINARY} and {@code Byte[]} * A type that maps JDBC {@link java.sql.Types#LONGVARBINARY LONGVARBINARY} and {@code Byte[]}
* *
* @author Strong Liu * @author Strong Liu
*/ */
public class WrappedImageType extends AbstractSingleColumnStandardBasicType<Byte[]> { public class WrappedImageType extends AbstractSingleColumnStandardBasicType<Byte[]> {

View File

@ -1,28 +1,28 @@
/** /**
* Test package for metatata facilities * Test package for metadata facilities
* It contains an example of filter metadata * It contains an example of filter metadata
*/ */
@TypeDefs( @TypeDefs(
{ {
@TypeDef( @TypeDef(
name = "wrapped_char_text", name = "wrapped_char_text",
typeClass = org.hibernate.test.annotations.lob.CharacterArrayTextType.class typeClass = org.hibernate.test.annotations.lob.CharacterArrayTextType.class
), ),
@TypeDef( @TypeDef(
name = "char_text", name = "char_text",
typeClass = org.hibernate.test.annotations.lob.PrimitiveCharacterArrayTextType.class typeClass = org.hibernate.test.annotations.lob.PrimitiveCharacterArrayTextType.class
), ),
@TypeDef( @TypeDef(
name = "wrapped_image", name = "wrapped_image",
typeClass = org.hibernate.test.annotations.lob.WrappedImageType.class typeClass = org.hibernate.test.annotations.lob.WrappedImageType.class
), ),
@TypeDef( @TypeDef(
name = "serializable_image", name = "serializable_image",
typeClass = org.hibernate.test.annotations.lob.SerializableToImageType.class typeClass = org.hibernate.test.annotations.lob.SerializableToImageType.class
) )
} }
) ) package org.hibernate.test.annotations.lob;
package org.hibernate.test.annotations.lob;
import org.hibernate.annotations.TypeDef; import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs; import org.hibernate.annotations.TypeDefs;