HHH-7484 Removing obsolete //$Id$ and adding missing license headers (no functional changes)
This commit is contained in:
parent
7f3ad01b50
commit
672368931f
|
@ -22,6 +22,7 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public abstract class AbstractLobTest<B extends AbstractBook, C extends Abstract
|
|||
try {
|
||||
return getBookClass().newInstance();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch ( Exception 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 {
|
||||
return getCompiledCodeClass().newInstance();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new RuntimeException( "Could not create an instance of type " + getCompiledCodeClass().getName(), ex );
|
||||
catch ( Exception ex ) {
|
||||
throw new RuntimeException(
|
||||
"Could not create an instance of type " + getCompiledCodeClass().getName(),
|
||||
ex
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
//$Id: $
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
|
@ -24,6 +23,7 @@
|
|||
*
|
||||
*/
|
||||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
|
||||
import org.hibernate.type.descriptor.java.CharacterArrayTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.LongVarcharTypeDescriptor;
|
||||
|
|
|
@ -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;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
|
|
@ -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;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Dog implements Serializable {
|
||||
|
|
|
@ -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;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
//$Id: $
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
|
@ -24,6 +23,7 @@
|
|||
*
|
||||
*/
|
||||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
@ -31,7 +31,7 @@ import javax.persistence.Id;
|
|||
/**
|
||||
* An entity containing data that is materialized into a byte array immediately.
|
||||
* The hibernate type mapped for {@link #longByteArray} determines the SQL type
|
||||
* asctually used.
|
||||
* actually used.
|
||||
*
|
||||
* @author Gail Badner
|
||||
*/
|
||||
|
@ -52,7 +52,7 @@ public class ImageHolder {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
@org.hibernate.annotations.Type(type="image")
|
||||
@org.hibernate.annotations.Type(type = "image")
|
||||
public byte[] getLongByteArray() {
|
||||
return longByteArray;
|
||||
}
|
||||
|
@ -60,7 +60,8 @@ public class ImageHolder {
|
|||
public void setLongByteArray(byte[] longByteArray) {
|
||||
this.longByteArray = longByteArray;
|
||||
}
|
||||
@org.hibernate.annotations.Type(type="serializable_image")
|
||||
|
||||
@org.hibernate.annotations.Type(type = "serializable_image")
|
||||
public Dog getDog() {
|
||||
return dog;
|
||||
}
|
||||
|
@ -68,7 +69,8 @@ public class ImageHolder {
|
|||
public void setDog(Dog dog) {
|
||||
this.dog = dog;
|
||||
}
|
||||
@org.hibernate.annotations.Type(type="wrapped_image")
|
||||
|
||||
@org.hibernate.annotations.Type(type = "wrapped_image")
|
||||
public Byte[] getPicByteArray() {
|
||||
return picByteArray;
|
||||
}
|
||||
|
|
|
@ -42,74 +42,74 @@ import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
|||
*
|
||||
* @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 {
|
||||
private static final int ARRAY_SIZE = 10000;
|
||||
|
||||
@Test
|
||||
public void testBoundedLongByteArrayAccess() {
|
||||
byte[] original = buildRecursively(ARRAY_SIZE, true);
|
||||
byte[] changed = buildRecursively(ARRAY_SIZE, false);
|
||||
byte[] original = buildRecursively( ARRAY_SIZE, true );
|
||||
byte[] changed = buildRecursively( ARRAY_SIZE, false );
|
||||
|
||||
Session s = openSession();
|
||||
s.beginTransaction();
|
||||
ImageHolder entity = new ImageHolder();
|
||||
s.save(entity);
|
||||
s.save( entity );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
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.getDog() );
|
||||
Assert.assertNull( entity.getPicByteArray() );
|
||||
entity.setLongByteArray(original);
|
||||
entity.setLongByteArray( original );
|
||||
Dog dog = new Dog();
|
||||
dog.setName("rabbit");
|
||||
entity.setDog(dog);
|
||||
entity.setPicByteArray(wrapPrimitive(original));
|
||||
dog.setName( "rabbit" );
|
||||
entity.setDog( dog );
|
||||
entity.setPicByteArray( wrapPrimitive( original ) );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
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 );
|
||||
assertEquals(original, entity.getLongByteArray());
|
||||
assertEquals( original, entity.getLongByteArray() );
|
||||
Assert.assertEquals( ARRAY_SIZE, entity.getPicByteArray().length );
|
||||
assertEquals(original, unwrapNonPrimitive(entity.getPicByteArray()));
|
||||
assertEquals( original, unwrapNonPrimitive( entity.getPicByteArray() ) );
|
||||
Assert.assertNotNull( entity.getDog() );
|
||||
Assert.assertEquals( dog.getName(), entity.getDog().getName() );
|
||||
entity.setLongByteArray(changed);
|
||||
entity.setPicByteArray(wrapPrimitive(changed));
|
||||
dog.setName("papa");
|
||||
entity.setDog(dog);
|
||||
entity.setLongByteArray( changed );
|
||||
entity.setPicByteArray( wrapPrimitive( changed ) );
|
||||
dog.setName( "papa" );
|
||||
entity.setDog( dog );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
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 );
|
||||
assertEquals(changed, entity.getLongByteArray());
|
||||
assertEquals( changed, entity.getLongByteArray() );
|
||||
Assert.assertEquals( ARRAY_SIZE, entity.getPicByteArray().length );
|
||||
assertEquals(changed, unwrapNonPrimitive(entity.getPicByteArray()));
|
||||
assertEquals( changed, unwrapNonPrimitive( entity.getPicByteArray() ) );
|
||||
Assert.assertNotNull( entity.getDog() );
|
||||
Assert.assertEquals( dog.getName(), entity.getDog().getName() );
|
||||
entity.setLongByteArray(null);
|
||||
entity.setPicByteArray(null);
|
||||
entity.setDog(null);
|
||||
entity.setLongByteArray( null );
|
||||
entity.setPicByteArray( null );
|
||||
entity.setDog( null );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
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.getDog() );
|
||||
Assert.assertNull( entity.getPicByteArray() );
|
||||
s.delete(entity);
|
||||
s.delete( entity );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public class ImageTest extends BaseCoreFunctionalTestCase {
|
|||
private Byte[] wrapPrimitive(byte[] bytes) {
|
||||
int length = bytes.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] );
|
||||
}
|
||||
return result;
|
||||
|
@ -126,7 +126,7 @@ public class ImageTest extends BaseCoreFunctionalTestCase {
|
|||
private byte[] unwrapNonPrimitive(Byte[] bytes) {
|
||||
int length = bytes.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();
|
||||
}
|
||||
return result;
|
||||
|
@ -134,21 +134,21 @@ public class ImageTest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
private byte[] buildRecursively(int size, boolean on) {
|
||||
byte[] data = new byte[size];
|
||||
data[0] = mask(on);
|
||||
for (int i = 0; i < size; i++) {
|
||||
data[i] = mask(on);
|
||||
data[0] = mask( on );
|
||||
for ( int i = 0; i < size; i++ ) {
|
||||
data[i] = mask( on );
|
||||
on = !on;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (!ArrayHelper.isEquals( val1, val2 )) {
|
||||
throw new AssertionFailedError("byte arrays did not match");
|
||||
if ( !ArrayHelper.isEquals( val1, val2 ) ) {
|
||||
throw new AssertionFailedError( "byte arrays did not match" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
//$Id$
|
||||
/*
|
||||
* 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
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
|
@ -25,14 +24,12 @@
|
|||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@RequiresDialectFeature(DialectChecks.SupportsExpectedLobUsagePattern.class)
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public class LobTest extends AbstractLobTest<Book, CompiledCode> {
|
||||
@Override
|
||||
protected Class<Book> getBookClass() {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
//$Id: $
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
|
@ -24,6 +23,7 @@
|
|||
*
|
||||
*/
|
||||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
@ -62,6 +62,7 @@ public class LongStringHolder {
|
|||
public void setLongString(String longString) {
|
||||
this.longString = longString;
|
||||
}
|
||||
|
||||
@Type(type = "char_text")
|
||||
public char[] getName() {
|
||||
return name;
|
||||
|
@ -70,6 +71,7 @@ public class LongStringHolder {
|
|||
public void setName(char[] name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Type(type = "wrapped_char_text")
|
||||
public Character[] getWhatEver() {
|
||||
return whatEver;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
|
|
|
@ -51,8 +51,12 @@ public class MaterializedBlobTest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
@Test
|
||||
public void testTypeSelection() {
|
||||
int index = sessionFactory().getEntityPersister( MaterializedBlobEntity.class.getName() ).getEntityMetamodel().getPropertyIndex( "theBytes" );
|
||||
Type type = sessionFactory().getEntityPersister( MaterializedBlobEntity.class.getName() ).getEntityMetamodel().getProperties()[index].getType();
|
||||
int index = sessionFactory().getEntityPersister( MaterializedBlobEntity.class.getName() )
|
||||
.getEntityMetamodel()
|
||||
.getPropertyIndex( "theBytes" );
|
||||
Type type = sessionFactory().getEntityPersister( MaterializedBlobEntity.class.getName() )
|
||||
.getEntityMetamodel()
|
||||
.getProperties()[index].getType();
|
||||
assertEquals( MaterializedBlobType.INSTANCE, type );
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
//$Id: $
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
|
@ -24,6 +23,7 @@
|
|||
*
|
||||
*/
|
||||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
|
||||
import org.hibernate.type.descriptor.java.PrimitiveCharacterArrayTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.LongVarcharTypeDescriptor;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
|
||||
|
@ -39,7 +40,10 @@ public class SerializableToImageType extends AbstractSingleColumnStandardBasicTy
|
|||
public static final PrimitiveCharacterArrayTextType INSTANCE = new PrimitiveCharacterArrayTextType();
|
||||
|
||||
public SerializableToImageType() {
|
||||
super( LongVarbinaryTypeDescriptor.INSTANCE, new SerializableTypeDescriptor<Serializable>( Serializable.class ) );
|
||||
super(
|
||||
LongVarbinaryTypeDescriptor.INSTANCE,
|
||||
new SerializableTypeDescriptor<Serializable>( Serializable.class )
|
||||
);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
|
|
@ -43,7 +43,7 @@ import static org.junit.Assert.assertNull;
|
|||
*
|
||||
* @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 {
|
||||
|
||||
@Override
|
||||
|
@ -55,33 +55,37 @@ public class TextTest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
@Test
|
||||
public void testBoundedLongStringAccess() {
|
||||
String original = buildRecursively(LONG_STRING_SIZE, 'x');
|
||||
String changed = buildRecursively(LONG_STRING_SIZE, 'y');
|
||||
String original = buildRecursively( LONG_STRING_SIZE, 'x' );
|
||||
String changed = buildRecursively( LONG_STRING_SIZE, 'y' );
|
||||
|
||||
Session s = openSession();
|
||||
s.beginTransaction();
|
||||
LongStringHolder entity = new LongStringHolder();
|
||||
s.save(entity);
|
||||
s.save( entity );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
s.beginTransaction();
|
||||
entity = (LongStringHolder) s.get(LongStringHolder.class, entity
|
||||
.getId());
|
||||
assertNull(entity.getLongString());
|
||||
assertNull(entity.getName());
|
||||
assertNull(entity.getWhatEver());
|
||||
entity.setLongString(original);
|
||||
entity.setName(original.toCharArray());
|
||||
entity.setWhatEver(wrapPrimitive(original.toCharArray()));
|
||||
entity = ( LongStringHolder ) s.get(
|
||||
LongStringHolder.class, entity
|
||||
.getId()
|
||||
);
|
||||
assertNull( entity.getLongString() );
|
||||
assertNull( entity.getName() );
|
||||
assertNull( entity.getWhatEver() );
|
||||
entity.setLongString( original );
|
||||
entity.setName( original.toCharArray() );
|
||||
entity.setWhatEver( wrapPrimitive( original.toCharArray() ) );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
s.beginTransaction();
|
||||
entity = (LongStringHolder) s.get(LongStringHolder.class, entity
|
||||
.getId());
|
||||
entity = ( LongStringHolder ) s.get(
|
||||
LongStringHolder.class, entity
|
||||
.getId()
|
||||
);
|
||||
Assert.assertEquals( LONG_STRING_SIZE, entity.getLongString().length() );
|
||||
Assert.assertEquals( original, entity.getLongString() );
|
||||
Assert.assertNotNull( entity.getName() );
|
||||
|
@ -90,16 +94,18 @@ public class TextTest extends BaseCoreFunctionalTestCase {
|
|||
Assert.assertNotNull( entity.getWhatEver() );
|
||||
Assert.assertEquals( LONG_STRING_SIZE, entity.getWhatEver().length );
|
||||
assertEquals( original.toCharArray(), unwrapNonPrimitive( entity.getWhatEver() ) );
|
||||
entity.setLongString(changed);
|
||||
entity.setName(changed.toCharArray());
|
||||
entity.setWhatEver(wrapPrimitive(changed.toCharArray()));
|
||||
entity.setLongString( changed );
|
||||
entity.setName( changed.toCharArray() );
|
||||
entity.setWhatEver( wrapPrimitive( changed.toCharArray() ) );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
s.beginTransaction();
|
||||
entity = (LongStringHolder) s.get(LongStringHolder.class, entity
|
||||
.getId());
|
||||
entity = ( LongStringHolder ) s.get(
|
||||
LongStringHolder.class, entity
|
||||
.getId()
|
||||
);
|
||||
Assert.assertEquals( LONG_STRING_SIZE, entity.getLongString().length() );
|
||||
Assert.assertEquals( changed, entity.getLongString() );
|
||||
Assert.assertNotNull( entity.getName() );
|
||||
|
@ -108,34 +114,36 @@ public class TextTest extends BaseCoreFunctionalTestCase {
|
|||
Assert.assertNotNull( entity.getWhatEver() );
|
||||
Assert.assertEquals( LONG_STRING_SIZE, entity.getWhatEver().length );
|
||||
assertEquals( changed.toCharArray(), unwrapNonPrimitive( entity.getWhatEver() ) );
|
||||
entity.setLongString(null);
|
||||
entity.setName(null);
|
||||
entity.setWhatEver(null);
|
||||
entity.setLongString( null );
|
||||
entity.setName( null );
|
||||
entity.setWhatEver( null );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
s.beginTransaction();
|
||||
entity = (LongStringHolder) s.get(LongStringHolder.class, entity
|
||||
.getId());
|
||||
assertNull(entity.getLongString());
|
||||
assertNull(entity.getName());
|
||||
assertNull(entity.getWhatEver());
|
||||
s.delete(entity);
|
||||
entity = ( LongStringHolder ) s.get(
|
||||
LongStringHolder.class, entity
|
||||
.getId()
|
||||
);
|
||||
assertNull( entity.getLongString() );
|
||||
assertNull( entity.getName() );
|
||||
assertNull( entity.getWhatEver() );
|
||||
s.delete( entity );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
}
|
||||
|
||||
public static void assertEquals(char[] val1, char[] val2) {
|
||||
if (!ArrayHelper.isEquals( val1, val2 )) {
|
||||
throw new AssertionFailedError("byte arrays did not match");
|
||||
if ( !ArrayHelper.isEquals( val1, val2 ) ) {
|
||||
throw new AssertionFailedError( "byte arrays did not match" );
|
||||
}
|
||||
}
|
||||
|
||||
private String buildRecursively(int size, char baseChar) {
|
||||
StringBuilder buff = new StringBuilder();
|
||||
for (int i = 0; i < size; i++) {
|
||||
buff.append(baseChar);
|
||||
for ( int i = 0; i < size; i++ ) {
|
||||
buff.append( baseChar );
|
||||
}
|
||||
return buff.toString();
|
||||
}
|
||||
|
@ -143,8 +151,8 @@ public class TextTest extends BaseCoreFunctionalTestCase {
|
|||
private Character[] wrapPrimitive(char[] bytes) {
|
||||
int length = bytes.length;
|
||||
Character[] result = new Character[length];
|
||||
for (int index = 0; index < length; index++) {
|
||||
result[index] = Character.valueOf(bytes[index]);
|
||||
for ( int index = 0; index < length; index++ ) {
|
||||
result[index] = Character.valueOf( bytes[index] );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -152,7 +160,7 @@ public class TextTest extends BaseCoreFunctionalTestCase {
|
|||
private char[] unwrapNonPrimitive(Character[] bytes) {
|
||||
int length = bytes.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();
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
|
@ -34,7 +35,7 @@ import javax.persistence.Version;
|
|||
*/
|
||||
@Entity
|
||||
@Table(name = "ver_lob_book")
|
||||
public class VersionedBook extends AbstractBook{
|
||||
public class VersionedBook extends AbstractBook {
|
||||
private Integer id;
|
||||
private Integer version;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
|
@ -34,7 +35,7 @@ import javax.persistence.Version;
|
|||
* @author Gail Badner
|
||||
*/
|
||||
@Entity
|
||||
public class VersionedCompiledCode extends AbstractCompiledCode{
|
||||
public class VersionedCompiledCode extends AbstractCompiledCode {
|
||||
private Integer id;
|
||||
private Integer version;
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ public class VersionedLobTest extends AbstractLobTest<VersionedBook, VersionedCo
|
|||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-5811")
|
||||
@FailureExpected(jiraKey = "HHH-5811")
|
||||
public void testVersionUnchangedByteArray() throws Exception {
|
||||
Session s;
|
||||
Transaction tx;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
|
||||
import org.hibernate.type.descriptor.java.ByteArrayTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.LongVarbinaryTypeDescriptor;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Test package for metatata facilities
|
||||
* Test package for metadata facilities
|
||||
* It contains an example of filter metadata
|
||||
*/
|
||||
@TypeDefs(
|
||||
|
@ -21,8 +21,8 @@
|
|||
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.TypeDefs;
|
||||
|
||||
|
|
Loading…
Reference in New Issue