Hibernate SVN: r10812 - in trunk/HibernateExt/metadata/doc/reference/zh_cn: . styles
by hibernate-commits@lists.jboss.org
Author: caoxg
Date: 2006-11-15 10:13:14 -0500 (Wed, 15 Nov 2006)
New Revision: 10812
Modified:
trunk/HibernateExt/metadata/doc/reference/zh_cn/master.xml
trunk/HibernateExt/metadata/doc/reference/zh_cn/styles/html.xsl
trunk/HibernateExt/metadata/doc/reference/zh_cn/styles/html_chunk.xsl
Log:
updated to 3.0.2GA
Modified: trunk/HibernateExt/metadata/doc/reference/zh_cn/master.xml
===================================================================
--- trunk/HibernateExt/metadata/doc/reference/zh_cn/master.xml 2006-11-15 14:44:34 UTC (rev 10811)
+++ trunk/HibernateExt/metadata/doc/reference/zh_cn/master.xml 2006-11-15 15:13:14 UTC (rev 10812)
@@ -256,11 +256,8 @@
但前提是必须保证全文完整转载,包括完整的版权信息和作译者声明,并不能违反LGPL协议。
这里“完整”的含义是,不能进行任何删除/增添/注解。若有删除/增添/注解,必须逐段明确声明那些部分并非本文档的一部分。</para>
</sect1>
- </preface>
+
- <preface id="preface" revision="1">
- <title>前言</title>
-
<para>正如其他的ORM工具,Hibernate同样需要元数据来控制在不同数据表达形式之间的转化. 在Hibernate
2.x里,多数情况下表示映射关系的元数据保存在XML文本文件中.
还有一种方式就是Xdoclet,它可以在编译时利用Javadoc中的源码注释信息来进行预处理.
Modified: trunk/HibernateExt/metadata/doc/reference/zh_cn/styles/html.xsl
===================================================================
--- trunk/HibernateExt/metadata/doc/reference/zh_cn/styles/html.xsl 2006-11-15 14:44:34 UTC (rev 10811)
+++ trunk/HibernateExt/metadata/doc/reference/zh_cn/styles/html.xsl 2006-11-15 15:13:14 UTC (rev 10812)
@@ -15,7 +15,7 @@
-->
<!DOCTYPE xsl:stylesheet [
- <!ENTITY db_xsl_path "../../support/docbook-xsl/">
+ <!ENTITY db_xsl_path "../../../../../../Hibernate3/doc/reference/support/docbook-xsl/">
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
Modified: trunk/HibernateExt/metadata/doc/reference/zh_cn/styles/html_chunk.xsl
===================================================================
--- trunk/HibernateExt/metadata/doc/reference/zh_cn/styles/html_chunk.xsl 2006-11-15 14:44:34 UTC (rev 10811)
+++ trunk/HibernateExt/metadata/doc/reference/zh_cn/styles/html_chunk.xsl 2006-11-15 15:13:14 UTC (rev 10812)
@@ -15,7 +15,7 @@
-->
<!DOCTYPE xsl:stylesheet [
- <!ENTITY db_xsl_path "../../support/docbook-xsl/">
+ <!ENTITY db_xsl_path "../../../../../../Hibernate3/doc/reference/support/docbook-xsl/">
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
18 years, 1 month
Hibernate SVN: r10811 - branches/Branch_3_2/Hibernate3/src/org/hibernate/cache
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-15 09:44:34 -0500 (Wed, 15 Nov 2006)
New Revision: 10811
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/cache/UpdateTimestampsCache.java
Log:
HHH-2082 : bug in isUpToDate
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/cache/UpdateTimestampsCache.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/cache/UpdateTimestampsCache.java 2006-11-15 14:44:21 UTC (rev 10810)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/cache/UpdateTimestampsCache.java 2006-11-15 14:44:34 UTC (rev 10811)
@@ -85,8 +85,9 @@
if ( log.isDebugEnabled() ) {
log.debug("[" + space + "] last update timestamp: " + lastUpdate + ", result set timestamp: " + timestamp );
}
- return lastUpdate.longValue() < timestamp.longValue();
-// if ( lastUpdate.longValue() >= timestamp.longValue() ) return false;
+ if ( lastUpdate.longValue() >= timestamp.longValue() ) {
+ return false;
+ }
}
}
return true;
18 years, 1 month
Hibernate SVN: r10810 - trunk/Hibernate3/src/org/hibernate/cache
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-15 09:44:21 -0500 (Wed, 15 Nov 2006)
New Revision: 10810
Modified:
trunk/Hibernate3/src/org/hibernate/cache/UpdateTimestampsCache.java
Log:
HHH-2082 : bug in isUpToDate
Modified: trunk/Hibernate3/src/org/hibernate/cache/UpdateTimestampsCache.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/cache/UpdateTimestampsCache.java 2006-11-15 04:41:36 UTC (rev 10809)
+++ trunk/Hibernate3/src/org/hibernate/cache/UpdateTimestampsCache.java 2006-11-15 14:44:21 UTC (rev 10810)
@@ -85,8 +85,9 @@
if ( log.isDebugEnabled() ) {
log.debug("[" + space + "] last update timestamp: " + lastUpdate + ", result set timestamp: " + timestamp );
}
- return lastUpdate.longValue() < timestamp.longValue();
-// if ( lastUpdate.longValue() >= timestamp.longValue() ) return false;
+ if ( lastUpdate.longValue() >= timestamp.longValue() ) {
+ return false;
+ }
}
}
return true;
18 years, 1 month
Hibernate SVN: r10809 - in branches/Branch_3_2/HibernateExt/metadata/src: java/org/hibernate/validator java/org/hibernate/validator/resources test/org/hibernate/test/annotations/collectionelement test/org/hibernate/validator/test test/org/hibernate/validator/test/validator
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-11-14 23:41:36 -0500 (Tue, 14 Nov 2006)
New Revision: 10809
Added:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/NotEmpty.java
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/NotEmptyValidator.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/validator/
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/validator/Car.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/validator/NotEmptyTest.java
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages.properties
branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_fr.properties
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java
Log:
ANN-493 @NotEmpty
Added: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/NotEmpty.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/NotEmpty.java 2006-11-14 23:19:28 UTC (rev 10808)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/NotEmpty.java 2006-11-15 04:41:36 UTC (rev 10809)
@@ -0,0 +1,22 @@
+//$Id: $
+package org.hibernate.validator;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Check that a String is not empty (not null and length > 0)
+ * or that a Collection (or array) is not empty (not null and length > 0)
+ *
+ * @author Emmanuel Bernard
+ */
+@Documented
+(a)ValidatorClass(NotEmptyValidator.class)
+(a)Target({ElementType.METHOD, ElementType.FIELD})
+@Retention( RetentionPolicy.RUNTIME )
+public @interface NotEmpty {
+ String message() default "{validator.notEmpty}";
+}
Added: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/NotEmptyValidator.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/NotEmptyValidator.java 2006-11-14 23:19:28 UTC (rev 10808)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/NotEmptyValidator.java 2006-11-15 04:41:36 UTC (rev 10809)
@@ -0,0 +1,35 @@
+//$Id: $
+package org.hibernate.validator;
+
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * Check the non emptyness of the element
+ *
+ * @author Gavin King
+ */
+public class NotEmptyValidator implements Validator<NotEmpty>, Serializable {
+
+ public void initialize(NotEmpty parameters) {
+ }
+
+ public boolean isValid(Object value) {
+ if ( value == null ) return false;
+ if ( value.getClass().isArray() ) {
+ return Array.getLength( value ) > 0;
+ }
+ else if ( value instanceof Collection ) {
+ return ( (Collection) value ).size() > 0;
+ }
+ else if ( value instanceof Map ) {
+ return ( (Map) value ).size() > 0;
+ }
+ else {
+ return ( (String) value ).length() > 0;
+ }
+ }
+
+}
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages.properties
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages.properties 2006-11-14 23:19:28 UTC (rev 10808)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages.properties 2006-11-15 04:41:36 UTC (rev 10809)
@@ -9,4 +9,5 @@
validator.pattern=must match "{regex}"
validator.range=must be between {min} and {max}
validator.size=size must be between {min} and {max}
-validator.email=not a well-formed email address
\ No newline at end of file
+validator.email=not a well-formed email address
+validator.notEmpty=may not be null or empty
\ No newline at end of file
Modified: branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_fr.properties
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_fr.properties 2006-11-14 23:19:28 UTC (rev 10808)
+++ branches/Branch_3_2/HibernateExt/metadata/src/java/org/hibernate/validator/resources/DefaultValidatorMessages_fr.properties 2006-11-15 04:41:36 UTC (rev 10809)
@@ -9,4 +9,5 @@
validator.pattern=doit suivre "{regex}"
validator.range=doit �tre entre {min} et {max}
validator.size=le nombre d'�l�ments doit �tre entre {min} et {max}
-validator.email=Address email mal form�e
\ No newline at end of file
+validator.email=Address email mal form�e
+validator.notEmpty=ne peut pas �tre nul ou vide
\ No newline at end of file
Modified: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java 2006-11-14 23:19:28 UTC (rev 10808)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java 2006-11-15 04:41:36 UTC (rev 10809)
@@ -15,8 +15,9 @@
public void testSimpleElement() throws Exception {
assertEquals(
- "BoyFavoriteNumbers",
- getCfg().getCollectionMapping( Boy.class.getName() + '.' + "favoriteNumbers" ).getCollectionTable().getName()
+ "BoyFavoriteNumbers",
+ getCfg().getCollectionMapping( Boy.class.getName() + '.' + "favoriteNumbers" )
+ .getCollectionTable().getName()
);
Session s = openSession();
s.getTransaction().begin();
@@ -28,7 +29,7 @@
boy.getScorePerNickName().put( "Johnny", new Integer( 3 ) );
boy.getScorePerNickName().put( "Thing", new Integer( 5 ) );
int[] favNbrs = new int[4];
- for ( int index = 0; index < favNbrs.length - 1 ; index++ ) {
+ for ( int index = 0; index < favNbrs.length - 1; index++ ) {
favNbrs[index] = index * 3;
}
boy.setFavoriteNumbers( favNbrs );
@@ -47,8 +48,8 @@
assertNotNull( boy.getFavoriteNumbers() );
assertEquals( 3, boy.getFavoriteNumbers()[1] );
assertTrue( boy.getCharacters().contains( Character.CRAFTY ) );
- List result = s.createQuery( "select boy from Boy boy join boy.nickNames names where names = :name")
- .setParameter( "name", "Thing").list();
+ List result = s.createQuery( "select boy from Boy boy join boy.nickNames names where names = :name" )
+ .setParameter( "name", "Thing" ).list();
assertEquals( 1, result.size() );
s.delete( boy );
tx.commit();
@@ -110,7 +111,50 @@
}
+ public void testLazyCollectionofElements() throws Exception {
+ assertEquals(
+ "BoyFavoriteNumbers",
+ getCfg().getCollectionMapping( Boy.class.getName() + '.' + "favoriteNumbers" )
+ .getCollectionTable().getName()
+ );
+ Session s = openSession();
+ s.getTransaction().begin();
+ Boy boy = new Boy();
+ boy.setFirstName( "John" );
+ boy.setLastName( "Doe" );
+ boy.getNickNames().add( "Johnny" );
+ boy.getNickNames().add( "Thing" );
+ boy.getScorePerNickName().put( "Johnny", new Integer( 3 ) );
+ boy.getScorePerNickName().put( "Thing", new Integer( 5 ) );
+ int[] favNbrs = new int[4];
+ for ( int index = 0; index < favNbrs.length - 1; index++ ) {
+ favNbrs[index] = index * 3;
+ }
+ boy.setFavoriteNumbers( favNbrs );
+ boy.getCharacters().add( Character.GENTLE );
+ boy.getCharacters().add( Character.CRAFTY );
+ s.persist( boy );
+ s.getTransaction().commit();
+ s.clear();
+ Transaction tx = s.beginTransaction();
+ boy = (Boy) s.get( Boy.class, boy.getId() );
+ assertNotNull( boy.getNickNames() );
+ assertTrue( boy.getNickNames().contains( "Thing" ) );
+ assertNotNull( boy.getScorePerNickName() );
+ assertTrue( boy.getScorePerNickName().containsKey( "Thing" ) );
+ assertEquals( new Integer( 5 ), boy.getScorePerNickName().get( "Thing" ) );
+ assertNotNull( boy.getFavoriteNumbers() );
+ assertEquals( 3, boy.getFavoriteNumbers()[1] );
+ assertTrue( boy.getCharacters().contains( Character.CRAFTY ) );
+ List result = s.createQuery( "select boy from Boy boy join boy.nickNames names where names = :name" )
+ .setParameter( "name", "Thing" ).list();
+ assertEquals( 1, result.size() );
+ s.delete( boy );
+ tx.commit();
+ s.close();
+ }
+
protected Class[] getMappings() {
return new Class[]{
Boy.class,
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/validator/Car.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/validator/Car.java 2006-11-14 23:19:28 UTC (rev 10808)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/validator/Car.java 2006-11-15 04:41:36 UTC (rev 10809)
@@ -0,0 +1,14 @@
+//$Id: $
+package org.hibernate.validator.test.validator;
+
+import org.hibernate.validator.NotEmpty;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class Car {
+ @NotEmpty
+ public String name;
+ @NotEmpty
+ public String[] insurances;
+}
Added: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/validator/NotEmptyTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/validator/NotEmptyTest.java 2006-11-14 23:19:28 UTC (rev 10808)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/validator/test/validator/NotEmptyTest.java 2006-11-15 04:41:36 UTC (rev 10809)
@@ -0,0 +1,46 @@
+//$Id: $
+package org.hibernate.validator.test.validator;
+
+import java.util.ResourceBundle;
+import java.util.Locale;
+import java.util.Date;
+import java.io.Serializable;
+import java.math.BigInteger;
+
+import junit.framework.TestCase;
+import org.hibernate.validator.test.Address;
+import org.hibernate.validator.test.Brother;
+import org.hibernate.validator.test.Tv;
+import org.hibernate.validator.test.Vase;
+import org.hibernate.validator.test.Site;
+import org.hibernate.validator.test.Contact;
+import org.hibernate.validator.test.ValidatorTest;
+import org.hibernate.validator.ClassValidator;
+import org.hibernate.validator.InvalidValue;
+import org.hibernate.validator.MessageInterpolator;
+import org.hibernate.validator.Validator;
+
+/**
+ * @author Gavin King
+ */
+public class NotEmptyTest extends TestCase {
+
+ public void testBigInteger() throws Exception {
+ Car car = new Car();
+ ClassValidator<Car> classValidator = new ClassValidator<Car>( Car.class );
+ InvalidValue[] invalidValues = classValidator.getInvalidValues( car );
+ assertEquals( 2, invalidValues.length );
+ car.name = "";
+ invalidValues = classValidator.getInvalidValues( car );
+ assertEquals( 2, invalidValues.length );
+ car.name = "350Z";
+ invalidValues = classValidator.getInvalidValues( car );
+ assertEquals( 1, invalidValues.length );
+ car.insurances = new String[0];
+ invalidValues = classValidator.getInvalidValues( car );
+ assertEquals( 1, invalidValues.length );
+ car.insurances = new String[1];
+ invalidValues = classValidator.getInvalidValues( car );
+ assertEquals( 0, invalidValues.length );
+ }
+}
18 years, 1 month
Hibernate SVN: r10808 - in trunk/Hibernate3/test/org/hibernate/test: . lob
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-14 18:19:28 -0500 (Tue, 14 Nov 2006)
New Revision: 10808
Added:
trunk/Hibernate3/test/org/hibernate/test/lob/ClobHoldingEntity.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/lob/ClobHoldingEntity.java
trunk/Hibernate3/test/org/hibernate/test/lob/ClobTest.java
Modified:
trunk/Hibernate3/test/org/hibernate/test/AllTests.java
trunk/Hibernate3/test/org/hibernate/test/TestCase.java
Log:
lob tests
Modified: trunk/Hibernate3/test/org/hibernate/test/AllTests.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/AllTests.java 2006-11-14 23:18:34 UTC (rev 10807)
+++ trunk/Hibernate3/test/org/hibernate/test/AllTests.java 2006-11-14 23:19:28 UTC (rev 10808)
@@ -27,6 +27,7 @@
import org.hibernate.test.criteria.CriteriaQueryTest;
import org.hibernate.test.cuk.CompositePropertyRefTest;
import org.hibernate.test.cut.CompositeUserTypeTest;
+import org.hibernate.test.dialect.cache.SQLFunctionsInterSystemsTest;
import org.hibernate.test.discriminator.DiscriminatorTest;
import org.hibernate.test.dom4j.Dom4jAccessorTest;
import org.hibernate.test.dom4j.Dom4jManyToOneTest;
@@ -82,6 +83,8 @@
import org.hibernate.test.legacy.SQLFunctionsTest;
import org.hibernate.test.legacy.SQLLoaderTest;
import org.hibernate.test.legacy.StatisticsTest;
+import org.hibernate.test.lob.ClobTest;
+import org.hibernate.test.lob.LobTest;
import org.hibernate.test.manytomany.ManyToManyTest;
import org.hibernate.test.map.MapIndexFormulaTest;
import org.hibernate.test.mapcompelem.MapCompositeElementTest;
@@ -130,7 +133,6 @@
import org.hibernate.test.version.db.DbVersionTest;
import org.hibernate.test.version.sybase.SybaseTimestampVersioningTest;
import org.hibernate.test.where.WhereTest;
-import org.hibernate.test.dialect.cache.SQLFunctionsInterSystemsTest;
/**
* @author Gavin King
@@ -290,6 +292,8 @@
suite.addTest( UtilSuite.suite() );
suite.addTest( AnyTypeTest.suite() );
suite.addTest( SQLFunctionsInterSystemsTest.suite() );
+ suite.addTest( LobTest.suite() );
+ suite.addTest( ClobTest.suite() );
return filter( suite );
//return suite;
Modified: trunk/Hibernate3/test/org/hibernate/test/TestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/TestCase.java 2006-11-14 23:18:34 UTC (rev 10807)
+++ trunk/Hibernate3/test/org/hibernate/test/TestCase.java 2006-11-14 23:19:28 UTC (rev 10808)
@@ -30,6 +30,7 @@
import org.hibernate.dialect.TimesTenDialect;
import org.hibernate.dialect.DerbyDialect;
import org.hibernate.dialect.Cache71Dialect;
+import org.hibernate.dialect.H2Dialect;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.PersistentClass;
@@ -558,18 +559,91 @@
}
}
+ /**
+ * Expected LOB usage pattern is such that I can perform an insert
+ * via prepared statement with a parameter binding for a LOB value
+ * without crazy casting to JDBC driver implementation-specific classes...
+ * <p/>
+ * Part of the trickiness here is the fact that this is largely
+ * driver dependent. For Oracle, which is notoriously bad with
+ * LOB support in their drivers actually does a pretty good job with
+ * LOB support as of the 10.2.x versions of their drivers...
+ *
+ * @return True if expected usage pattern is support; false otherwise.
+ */
+ protected boolean supportsExpectedLobUsagePattern() {
+ // note : For H2, the insertions get truncated...
+ // note : For Derby, the insertions get truncated...
+ Class[] exceptions = new Class[] { H2Dialect.class, DerbyDialect.class };
+ if ( dialectIsOneOf( exceptions ) ) {
+ reportSkip( "database/driver does not support expected LOB usage pattern", "LOB support" );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Does the current dialect support propogating changes to LOB
+ * values back to the database? Talking about mutating the
+ * underlying value as opposed to supplying a new
+ * LOB instance...
+ *
+ * @return True if the changes are propogated back to the
+ * database; false otherwise.
+ */
+ protected boolean supportsLobValueChangePropogation() {
+ // note: at least my local MySQL 5.1 install shows this not working...
+ // note: at least my local SQL Server 2005 Express shows this not working...
+ Class[] exceptions = new Class[] {
+ HSQLDialect.class, MySQLDialect.class, SQLServerDialect.class
+ };
+ if ( dialectIsOneOf( exceptions ) ) {
+ reportSkip( "database/driver does not support propogating LOB value change back to database", "LOB support" );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Is it supported to materialize a LOB locator outside the transaction in
+ * which it was created?
+ * <p/>
+ * Again, part of the trickiness here is the fact that this is largely
+ * driver dependent.
+ * <p/>
+ * NOTE: all database I have tested which {@link #supportsExpectedLobUsagePattern()}
+ * also support the ability to materialize a LOB outside the owning transaction...
+ *
+ * @return True if unbounded materialization is supported; false otherwise.
+ */
+ protected boolean supportsUnboundedLobLocatorMaterialization() {
+ Class[] exceptions = new Class[] { }; // none known of...
+ if ( dialectIsOneOf( exceptions ) ) {
+ reportSkip( "database/driver does not support materializing a LOB locator outside the 'owning' transaction", "LOB support" );
+ return false;
+ }
+ return true;
+ }
+
+ private boolean dialectIs(Class dialectClass) {
+ return dialectClass.isInstance( getDialect() );
+ }
+
private boolean dialectIsNot(Class dialectClass) {
- return dialectIsNot( new Class[] { dialectClass } );
+ return ! dialectIs( dialectClass );
}
-
- private boolean dialectIsNot(Class[] dialectClasses) {
- for (int i = 0; i < dialectClasses.length; i++) {
- Class dialectClass = dialectClasses[i];
- if(dialectClass.isInstance(getDialect())) {
- return false;
+
+ private boolean dialectIsOneOf(Class[] dialectClasses) {
+ for ( int i = 0; i < dialectClasses.length; i++ ) {
+ if ( dialectClasses[i].isInstance( getDialect() ) ) {
+ return true;
}
}
- return true;
+ return false;
}
+ private boolean dialectIsNot(Class[] dialectClasses) {
+ return ! dialectIsOneOf( dialectClasses );
+ }
+
}
\ No newline at end of file
Added: trunk/Hibernate3/test/org/hibernate/test/lob/ClobHoldingEntity.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/lob/ClobHoldingEntity.hbm.xml 2006-11-14 23:18:34 UTC (rev 10807)
+++ trunk/Hibernate3/test/org/hibernate/test/lob/ClobHoldingEntity.hbm.xml 2006-11-14 23:19:28 UTC (rev 10808)
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.test.lob">
+
+ <class name="ClobHoldingEntity" table="CLOB_ENTITY">
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+ <property name="serialData" column="SER_DATA" type="text"/>
+ <property name="clobData" column="CLOB_DATA" type="clob" />
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/Hibernate3/test/org/hibernate/test/lob/ClobHoldingEntity.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/lob/ClobHoldingEntity.java 2006-11-14 23:18:34 UTC (rev 10807)
+++ trunk/Hibernate3/test/org/hibernate/test/lob/ClobHoldingEntity.java 2006-11-14 23:19:28 UTC (rev 10808)
@@ -0,0 +1,57 @@
+package org.hibernate.test.lob;
+
+import java.sql.Clob;
+
+/**
+ * Used to test materialized and lazy-materialized CLOB data.
+ * <p/>
+ * The {@link #serialData} field is used to hold CLOB data that is
+ * materialized into a String immediately (mapped via the
+ * Hibernate text type).
+ * <p/>
+ * The {@link #clobData} field is used to hold CLOB data that is
+ * materialized lazily via a JDBC CLOB locator (mapped via
+ * the Hibernate clob type).
+ *
+ * @author Steve Ebersole
+ */
+public class ClobHoldingEntity {
+ private Long id;
+ private String serialData;
+ private Clob clobData;
+
+ public ClobHoldingEntity() {
+ }
+
+ public ClobHoldingEntity(String serialData) {
+ this.serialData = serialData;
+ }
+
+ public ClobHoldingEntity(Clob clobData) {
+ this.clobData = clobData;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getSerialData() {
+ return serialData;
+ }
+
+ public void setSerialData(String serialData) {
+ this.serialData = serialData;
+ }
+
+ public Clob getClobData() {
+ return clobData;
+ }
+
+ public void setClobData(Clob clobData) {
+ this.clobData = clobData;
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/test/lob/ClobTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/lob/ClobTest.java 2006-11-14 23:18:34 UTC (rev 10807)
+++ trunk/Hibernate3/test/org/hibernate/test/lob/ClobTest.java 2006-11-14 23:19:28 UTC (rev 10808)
@@ -0,0 +1,189 @@
+package org.hibernate.test.lob;
+
+import java.sql.Clob;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.TestCase;
+import org.hibernate.Session;
+import org.hibernate.Hibernate;
+import org.hibernate.LockMode;
+
+/**
+ * Test various access scenarios for eager and lazy materialization
+ * of CLOB data, as well as bounded and unbounded materialization
+ * and mutation.
+ *
+ * @author Steve Ebersole
+ */
+public class ClobTest extends TestCase {
+ private static final int CLOB_SIZE = 10000;
+
+ public ClobTest(String name) {
+ super( name );
+ }
+
+ protected String[] getMappings() {
+ return new String[] { "lob/ClobHoldingEntity.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new TestSuite( ClobTest.class );
+ }
+
+ public void testBoundedMaterializedClobAccess() {
+ if ( !supportsExpectedLobUsagePattern() ) {
+ return;
+ }
+
+ String original = buildRecursively( CLOB_SIZE, 'x' );
+ String changed = buildRecursively( CLOB_SIZE, 'y' );
+
+ Session s = openSession();
+ s.beginTransaction();
+ ClobHoldingEntity entity = new ClobHoldingEntity();
+ entity.setSerialData( original );
+ s.save( entity );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ entity = ( ClobHoldingEntity ) s.get( ClobHoldingEntity.class, entity.getId() );
+ assertEquals( CLOB_SIZE, entity.getSerialData().length() );
+ assertEquals( original, entity.getSerialData() );
+ entity.setSerialData( changed );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ entity = ( ClobHoldingEntity ) s.get( ClobHoldingEntity.class, entity.getId() );
+ assertEquals( CLOB_SIZE, entity.getSerialData().length() );
+ assertEquals( changed, entity.getSerialData() );
+ s.delete( entity );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testBoundedClobLocatorAccess() throws Throwable {
+ if ( !supportsExpectedLobUsagePattern() ) {
+ return;
+ }
+
+ String original = buildRecursively( CLOB_SIZE, 'x' );
+ String changed = buildRecursively( CLOB_SIZE, 'y' );
+
+ Session s = openSession();
+ s.beginTransaction();
+ ClobHoldingEntity entity = new ClobHoldingEntity();
+ entity.setClobData( Hibernate.createClob( original ) );
+ s.save( entity );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ entity = ( ClobHoldingEntity ) s.get( ClobHoldingEntity.class, entity.getId() );
+ assertEquals( CLOB_SIZE, entity.getClobData().length() );
+ assertEquals( original, extractData( entity.getClobData() ) );
+ s.getTransaction().commit();
+ s.close();
+
+ // test mutation via setting the new clob data...
+ if ( supportsLobValueChangePropogation() ) {
+ s = openSession();
+ s.beginTransaction();
+ entity = ( ClobHoldingEntity ) s.get( ClobHoldingEntity.class, entity.getId(), LockMode.UPGRADE );
+ entity.getClobData().truncate( 1 );
+ entity.getClobData().setString( 1, changed );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ entity = ( ClobHoldingEntity ) s.get( ClobHoldingEntity.class, entity.getId(), LockMode.UPGRADE );
+ assertNotNull( entity.getClobData() );
+ assertEquals( CLOB_SIZE, entity.getClobData().length() );
+ assertEquals( changed, extractData( entity.getClobData() ) );
+ entity.getClobData().truncate( 1 );
+ entity.getClobData().setString( 1, original );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ // test mutation via supplying a new clob locator instance...
+ s = openSession();
+ s.beginTransaction();
+ entity = ( ClobHoldingEntity ) s.get( ClobHoldingEntity.class, entity.getId(), LockMode.UPGRADE );
+ assertNotNull( entity.getClobData() );
+ assertEquals( CLOB_SIZE, entity.getClobData().length() );
+ assertEquals( original, extractData( entity.getClobData() ) );
+ entity.setClobData( Hibernate.createClob( changed ) );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ entity = ( ClobHoldingEntity ) s.get( ClobHoldingEntity.class, entity.getId() );
+ assertEquals( CLOB_SIZE, entity.getClobData().length() );
+ assertEquals( changed, extractData( entity.getClobData() ) );
+ s.delete( entity );
+ s.getTransaction().commit();
+ s.close();
+
+ }
+
+ public void testUnboundedClobLocatorAccess() throws Throwable {
+ if ( !supportsExpectedLobUsagePattern() || ! supportsUnboundedLobLocatorMaterialization() ) {
+ return;
+ }
+
+ // Note: unbounded mutation of the underlying lob data is completely
+ // unsupported; most databases would not allow such a construct anyway.
+ // Thus here we are only testing materialization...
+
+ String original = buildRecursively( CLOB_SIZE, 'x' );
+
+ Session s = openSession();
+ s.beginTransaction();
+ ClobHoldingEntity entity = new ClobHoldingEntity();
+ entity.setClobData( Hibernate.createClob( original ) );
+ s.save( entity );
+ s.getTransaction().commit();
+ s.close();
+
+ // load the entity with the clob locator, and close the session/transaction;
+ // at that point it is unbounded...
+ s = openSession();
+ s.beginTransaction();
+ entity = ( ClobHoldingEntity ) s.get( ClobHoldingEntity.class, entity.getId() );
+ s.getTransaction().commit();
+ s.close();
+
+ assertEquals( CLOB_SIZE, entity.getClobData().length() );
+ assertEquals( original, extractData( entity.getClobData() ) );
+
+ s = openSession();
+ s.beginTransaction();
+ s.delete( entity );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ private String extractData(Clob clob) throws Throwable {
+ char[] data = new char[ (int) clob.length() ];
+ clob.getCharacterStream().read( data );
+ return new String( data );
+ }
+
+
+ private String buildRecursively(int size, char baseChar) {
+ StringBuffer buff = new StringBuffer();
+ for( int i = 0; i < size; i++ ) {
+ buff.append( baseChar );
+ }
+ return buff.toString();
+ }
+}
18 years, 1 month
Hibernate SVN: r10807 - in branches/Branch_3_2/Hibernate3/test/org/hibernate/test: . lob
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-11-14 18:18:34 -0500 (Tue, 14 Nov 2006)
New Revision: 10807
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/ClobHoldingEntity.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/ClobHoldingEntity.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/ClobTest.java
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestCase.java
Log:
lob tests
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java 2006-11-14 13:09:14 UTC (rev 10806)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java 2006-11-14 23:18:34 UTC (rev 10807)
@@ -131,6 +131,8 @@
import org.hibernate.test.version.sybase.SybaseTimestampVersioningTest;
import org.hibernate.test.where.WhereTest;
import org.hibernate.test.dialect.cache.SQLFunctionsInterSystemsTest;
+import org.hibernate.test.lob.LobTest;
+import org.hibernate.test.lob.ClobTest;
/**
* @author Gavin King
@@ -290,6 +292,8 @@
suite.addTest( UtilSuite.suite() );
suite.addTest( AnyTypeTest.suite() );
suite.addTest( SQLFunctionsInterSystemsTest.suite() );
+ suite.addTest( LobTest.suite() );
+ suite.addTest( ClobTest.suite() );
return filter( suite );
//return suite;
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestCase.java 2006-11-14 13:09:14 UTC (rev 10806)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/TestCase.java 2006-11-14 23:18:34 UTC (rev 10807)
@@ -30,6 +30,7 @@
import org.hibernate.dialect.TimesTenDialect;
import org.hibernate.dialect.DerbyDialect;
import org.hibernate.dialect.Cache71Dialect;
+import org.hibernate.dialect.H2Dialect;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.PersistentClass;
@@ -563,18 +564,91 @@
}
}
+ /**
+ * Expected LOB usage pattern is such that I can perform an insert
+ * via prepared statement with a parameter binding for a LOB value
+ * without crazy casting to JDBC driver implementation-specific classes...
+ * <p/>
+ * Part of the trickiness here is the fact that this is largely
+ * driver dependent. For Oracle, which is notoriously bad with
+ * LOB support in their drivers actually does a pretty good job with
+ * LOB support as of the 10.2.x versions of their drivers...
+ *
+ * @return True if expected usage pattern is support; false otherwise.
+ */
+ protected boolean supportsExpectedLobUsagePattern() {
+ // note : For H2, the insertions get truncated...
+ // note : For Derby, the insertions get truncated...
+ Class[] exceptions = new Class[] { H2Dialect.class, DerbyDialect.class };
+ if ( dialectIsOneOf( exceptions ) ) {
+ reportSkip( "database/driver does not support expected LOB usage pattern", "LOB support" );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Does the current dialect support propogating changes to LOB
+ * values back to the database? Talking about mutating the
+ * underlying value as opposed to supplying a new
+ * LOB instance...
+ *
+ * @return True if the changes are propogated back to the
+ * database; false otherwise.
+ */
+ protected boolean supportsLobValueChangePropogation() {
+ // note: at least my local MySQL 5.1 install shows this not working...
+ // note: at least my local SQL Server 2005 Express shows this not working...
+ Class[] exceptions = new Class[] {
+ HSQLDialect.class, MySQLDialect.class, SQLServerDialect.class
+ };
+ if ( dialectIsOneOf( exceptions ) ) {
+ reportSkip( "database/driver does not support propogating LOB value change back to database", "LOB support" );
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Is it supported to materialize a LOB locator outside the transaction in
+ * which it was created?
+ * <p/>
+ * Again, part of the trickiness here is the fact that this is largely
+ * driver dependent.
+ * <p/>
+ * NOTE: all database I have tested which {@link #supportsExpectedLobUsagePattern()}
+ * also support the ability to materialize a LOB outside the owning transaction...
+ *
+ * @return True if unbounded materialization is supported; false otherwise.
+ */
+ protected boolean supportsUnboundedLobLocatorMaterialization() {
+ Class[] exceptions = new Class[] { }; // none known of...
+ if ( dialectIsOneOf( exceptions ) ) {
+ reportSkip( "database/driver does not support materializing a LOB locator outside the 'owning' transaction", "LOB support" );
+ return false;
+ }
+ return true;
+ }
+
+ private boolean dialectIs(Class dialectClass) {
+ return dialectClass.isInstance( getDialect() );
+ }
+
private boolean dialectIsNot(Class dialectClass) {
- return dialectIsNot( new Class[] { dialectClass } );
+ return ! dialectIs( dialectClass );
}
-
- private boolean dialectIsNot(Class[] dialectClasses) {
- for (int i = 0; i < dialectClasses.length; i++) {
- Class dialectClass = dialectClasses[i];
- if(dialectClass.isInstance(getDialect())) {
- return false;
+
+ private boolean dialectIsOneOf(Class[] dialectClasses) {
+ for ( int i = 0; i < dialectClasses.length; i++ ) {
+ if ( dialectClasses[i].isInstance( getDialect() ) ) {
+ return true;
}
}
- return true;
+ return false;
}
+ private boolean dialectIsNot(Class[] dialectClasses) {
+ return ! dialectIsOneOf( dialectClasses );
+ }
+
}
\ No newline at end of file
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/ClobHoldingEntity.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/ClobHoldingEntity.hbm.xml 2006-11-14 13:09:14 UTC (rev 10806)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/ClobHoldingEntity.hbm.xml 2006-11-14 23:18:34 UTC (rev 10807)
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.test.lob">
+
+ <class name="ClobHoldingEntity" table="CLOB_ENTITY">
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+ <property name="serialData" column="SER_DATA" type="text"/>
+ <property name="clobData" column="CLOB_DATA" type="clob" />
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/ClobHoldingEntity.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/ClobHoldingEntity.java 2006-11-14 13:09:14 UTC (rev 10806)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/ClobHoldingEntity.java 2006-11-14 23:18:34 UTC (rev 10807)
@@ -0,0 +1,57 @@
+package org.hibernate.test.lob;
+
+import java.sql.Clob;
+
+/**
+ * Used to test materialized and lazy-materialized CLOB data.
+ * <p/>
+ * The {@link #serialData} field is used to hold CLOB data that is
+ * materialized into a String immediately (mapped via the
+ * Hibernate text type).
+ * <p/>
+ * The {@link #clobData} field is used to hold CLOB data that is
+ * materialized lazily via a JDBC CLOB locator (mapped via
+ * the Hibernate clob type).
+ *
+ * @author Steve Ebersole
+ */
+public class ClobHoldingEntity {
+ private Long id;
+ private String serialData;
+ private Clob clobData;
+
+ public ClobHoldingEntity() {
+ }
+
+ public ClobHoldingEntity(String serialData) {
+ this.serialData = serialData;
+ }
+
+ public ClobHoldingEntity(Clob clobData) {
+ this.clobData = clobData;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getSerialData() {
+ return serialData;
+ }
+
+ public void setSerialData(String serialData) {
+ this.serialData = serialData;
+ }
+
+ public Clob getClobData() {
+ return clobData;
+ }
+
+ public void setClobData(Clob clobData) {
+ this.clobData = clobData;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/ClobTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/ClobTest.java 2006-11-14 13:09:14 UTC (rev 10806)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/lob/ClobTest.java 2006-11-14 23:18:34 UTC (rev 10807)
@@ -0,0 +1,191 @@
+package org.hibernate.test.lob;
+
+import java.sql.Clob;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.hibernate.test.TestCase;
+import org.hibernate.Session;
+import org.hibernate.Hibernate;
+import org.hibernate.LockMode;
+
+import org.h2.engine.Constants;
+
+/**
+ * Test various access scenarios for eager and lazy materialization
+ * of CLOB data, as well as bounded and unbounded materialization
+ * and mutation.
+ *
+ * @author Steve Ebersole
+ */
+public class ClobTest extends TestCase {
+ private static final int CLOB_SIZE = 10000;
+
+ public ClobTest(String name) {
+ super( name );
+ }
+
+ protected String[] getMappings() {
+ return new String[] { "lob/ClobHoldingEntity.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new TestSuite( ClobTest.class );
+ }
+
+ public void testBoundedMaterializedClobAccess() {
+ if ( !supportsExpectedLobUsagePattern() ) {
+ return;
+ }
+
+ String original = buildRecursively( CLOB_SIZE, 'x' );
+ String changed = buildRecursively( CLOB_SIZE, 'y' );
+
+ Session s = openSession();
+ s.beginTransaction();
+ ClobHoldingEntity entity = new ClobHoldingEntity();
+ entity.setSerialData( original );
+ s.save( entity );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ entity = ( ClobHoldingEntity ) s.get( ClobHoldingEntity.class, entity.getId() );
+ assertEquals( CLOB_SIZE, entity.getSerialData().length() );
+ assertEquals( original, entity.getSerialData() );
+ entity.setSerialData( changed );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ entity = ( ClobHoldingEntity ) s.get( ClobHoldingEntity.class, entity.getId() );
+ assertEquals( CLOB_SIZE, entity.getSerialData().length() );
+ assertEquals( changed, entity.getSerialData() );
+ s.delete( entity );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testBoundedClobLocatorAccess() throws Throwable {
+ if ( !supportsExpectedLobUsagePattern() ) {
+ return;
+ }
+
+ String original = buildRecursively( CLOB_SIZE, 'x' );
+ String changed = buildRecursively( CLOB_SIZE, 'y' );
+
+ Session s = openSession();
+ s.beginTransaction();
+ ClobHoldingEntity entity = new ClobHoldingEntity();
+ entity.setClobData( Hibernate.createClob( original ) );
+ s.save( entity );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ entity = ( ClobHoldingEntity ) s.get( ClobHoldingEntity.class, entity.getId() );
+ assertEquals( CLOB_SIZE, entity.getClobData().length() );
+ assertEquals( original, extractData( entity.getClobData() ) );
+ s.getTransaction().commit();
+ s.close();
+
+ // test mutation via setting the new clob data...
+ if ( supportsLobValueChangePropogation() ) {
+ s = openSession();
+ s.beginTransaction();
+ entity = ( ClobHoldingEntity ) s.get( ClobHoldingEntity.class, entity.getId(), LockMode.UPGRADE );
+ entity.getClobData().truncate( 1 );
+ entity.getClobData().setString( 1, changed );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ entity = ( ClobHoldingEntity ) s.get( ClobHoldingEntity.class, entity.getId(), LockMode.UPGRADE );
+ assertNotNull( entity.getClobData() );
+ assertEquals( CLOB_SIZE, entity.getClobData().length() );
+ assertEquals( changed, extractData( entity.getClobData() ) );
+ entity.getClobData().truncate( 1 );
+ entity.getClobData().setString( 1, original );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ // test mutation via supplying a new clob locator instance...
+ s = openSession();
+ s.beginTransaction();
+ entity = ( ClobHoldingEntity ) s.get( ClobHoldingEntity.class, entity.getId(), LockMode.UPGRADE );
+ assertNotNull( entity.getClobData() );
+ assertEquals( CLOB_SIZE, entity.getClobData().length() );
+ assertEquals( original, extractData( entity.getClobData() ) );
+ entity.setClobData( Hibernate.createClob( changed ) );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ entity = ( ClobHoldingEntity ) s.get( ClobHoldingEntity.class, entity.getId() );
+ assertEquals( CLOB_SIZE, entity.getClobData().length() );
+ assertEquals( changed, extractData( entity.getClobData() ) );
+ s.delete( entity );
+ s.getTransaction().commit();
+ s.close();
+
+ }
+
+ public void testUnboundedClobLocatorAccess() throws Throwable {
+ if ( !supportsExpectedLobUsagePattern() || ! supportsUnboundedLobLocatorMaterialization() ) {
+ return;
+ }
+
+ // Note: unbounded mutation of the underlying lob data is completely
+ // unsupported; most databases would not allow such a construct anyway.
+ // Thus here we are only testing materialization...
+
+ String original = buildRecursively( CLOB_SIZE, 'x' );
+
+ Session s = openSession();
+ s.beginTransaction();
+ ClobHoldingEntity entity = new ClobHoldingEntity();
+ entity.setClobData( Hibernate.createClob( original ) );
+ s.save( entity );
+ s.getTransaction().commit();
+ s.close();
+
+ // load the entity with the clob locator, and close the session/transaction;
+ // at that point it is unbounded...
+ s = openSession();
+ s.beginTransaction();
+ entity = ( ClobHoldingEntity ) s.get( ClobHoldingEntity.class, entity.getId() );
+ s.getTransaction().commit();
+ s.close();
+
+ assertEquals( CLOB_SIZE, entity.getClobData().length() );
+ assertEquals( original, extractData( entity.getClobData() ) );
+
+ s = openSession();
+ s.beginTransaction();
+ s.delete( entity );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ private String extractData(Clob clob) throws Throwable {
+ char[] data = new char[ (int) clob.length() ];
+ clob.getCharacterStream().read( data );
+ return new String( data );
+ }
+
+
+ private String buildRecursively(int size, char baseChar) {
+ StringBuffer buff = new StringBuffer();
+ for( int i = 0; i < size; i++ ) {
+ buff.append( baseChar );
+ }
+ return buff.toString();
+ }
+}
18 years, 1 month
Hibernate SVN: r10806 - in branches/Branch_3_2/HibernateExt/tools/src: test/org/hibernate/tool/hbm2x testsupport testsupport/formatting
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-14 08:09:14 -0500 (Tue, 14 Nov 2006)
New Revision: 10806
Added:
branches/Branch_3_2/HibernateExt/tools/src/testsupport/formatting/Simple5One.java5
Removed:
branches/Branch_3_2/HibernateExt/tools/src/testsupport/formatting/Simple5One.java
Modified:
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Bungalow.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Passenger.hbm.xml
branches/Branch_3_2/HibernateExt/tools/src/testsupport/anttest-build.xml
branches/Branch_3_2/HibernateExt/tools/src/testsupport/javaformattest-build.xml
Log:
javaformat test
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Bungalow.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Bungalow.hbm.xml 2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Bungalow.hbm.xml 2006-11-14 13:09:14 UTC (rev 10806)
@@ -18,6 +18,9 @@
<property name="lastModified" type="timestamp"/>
<property name="dayFree" type="date"/>
<property name="timeFree" type="time"/>
+
+ <many-to-one name="mascot" not-null="true" class="Bungalow"/>
+
</class>
</hibernate-mapping>
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Passenger.hbm.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Passenger.hbm.xml 2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/Passenger.hbm.xml 2006-11-14 13:09:14 UTC (rev 10806)
@@ -24,7 +24,8 @@
lazy="false"
update="true"
insert="true"
- access="property">
+ access="property"
+ >
<column name="currentTrainCity"/>
<column name="currentTrainLine"/>
</many-to-one>
Modified: branches/Branch_3_2/HibernateExt/tools/src/testsupport/anttest-build.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/testsupport/anttest-build.xml 2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/HibernateExt/tools/src/testsupport/anttest-build.xml 2006-11-14 13:09:14 UTC (rev 10806)
@@ -298,7 +298,7 @@
<copy file="ejb3test-hibernate.cfg.xml" tofile="${build.dir}/ejb3/classes/ejb3test-hibernate.cfg.xml" />
<hibernatetool destdir="${build.dir}">
- <jpaconfiguration persistenceunit="ejb3test"/>
+ <jpaconfiguration persistenceunit="ejb3test" entityresolver="DummyEntityResolver"/>
<classpath>
<path location="${build.dir}/ejb3/classes" />
</classpath>
Deleted: branches/Branch_3_2/HibernateExt/tools/src/testsupport/formatting/Simple5One.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/testsupport/formatting/Simple5One.java 2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/HibernateExt/tools/src/testsupport/formatting/Simple5One.java 2006-11-14 13:09:14 UTC (rev 10806)
@@ -1,9 +0,0 @@
-package formatting;
-
-@Override // intentional that his will give compile error.
-public
- class
- Simple5One {
-
-
-}
Added: branches/Branch_3_2/HibernateExt/tools/src/testsupport/formatting/Simple5One.java5
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/testsupport/formatting/Simple5One.java5 2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/HibernateExt/tools/src/testsupport/formatting/Simple5One.java5 2006-11-14 13:09:14 UTC (rev 10806)
@@ -0,0 +1,9 @@
+package formatting;
+
+@Override // intentional that his will give compile error.
+public
+ class
+ Simple5One {
+
+
+}
Modified: branches/Branch_3_2/HibernateExt/tools/src/testsupport/javaformattest-build.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/testsupport/javaformattest-build.xml 2006-11-14 13:07:51 UTC (rev 10805)
+++ branches/Branch_3_2/HibernateExt/tools/src/testsupport/javaformattest-build.xml 2006-11-14 13:09:14 UTC (rev 10806)
@@ -30,7 +30,7 @@
<target name="prepare">
<copy todir="${build.dir}">
- <fileset dir="." includes="formatting/**/*.java"/>
+ <fileset dir="." includes="formatting/**/*"/>
</copy>
</target>
@@ -39,7 +39,7 @@
<javaformatter>
<fileset dir="${build.dir}">
- <include name="formatting/**/*.java"/>
+ <include name="formatting/**/*"/>
</fileset>
</javaformatter>
</target>
@@ -49,7 +49,7 @@
<javaformatter configurationfile="emptyconfig.properties">
<fileset dir="${build.dir}">
- <include name="formatting/**/*.java"/>
+ <include name="formatting/**/*"/>
</fileset>
</javaformatter>
</target>
@@ -59,7 +59,7 @@
<javaformatter>
<fileset dir="${build.dir}">
- <include name="formatting/**/*.java"/>
+ <include name="formatting/**/*"/>
</fileset>
</javaformatter>
</target>
18 years, 1 month
Hibernate SVN: r10805 - branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-14 08:07:51 -0500 (Tue, 14 Nov 2006)
New Revision: 10805
Modified:
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntAllTests.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/JavaFormatterTest.java
Log:
javaformat test
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntAllTests.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntAllTests.java 2006-11-14 13:07:25 UTC (rev 10804)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntAllTests.java 2006-11-14 13:07:51 UTC (rev 10805)
@@ -10,6 +10,7 @@
//$JUnit-BEGIN$
suite.addTestSuite(HibernateToolTest.class);
suite.addTestSuite(SeamAntTest.class);
+ suite.addTestSuite(JavaFormatterTask.class);
//$JUnit-END$
return suite;
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/JavaFormatterTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/JavaFormatterTest.java 2006-11-14 13:07:25 UTC (rev 10804)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/JavaFormatterTest.java 2006-11-14 13:07:51 UTC (rev 10805)
@@ -54,7 +54,7 @@
executeTarget("prepare");
- File file = new File(project.getProperty( "build.dir" ), "formatting/Simple5One.java");
+ File file = new File(project.getProperty( "build.dir" ), "formatting/Simple5One.java5");
assertFileAndExists( file );
long before = file.lastModified();
@@ -87,7 +87,7 @@
executeTarget("prepare");
- File jdk5file = new File(project.getProperty( "build.dir" ), "formatting/Simple5One.java");
+ File jdk5file = new File(project.getProperty( "build.dir" ), "formatting/Simple5One.java5");
File jdkfile = new File(project.getProperty( "build.dir" ), "formatting/SimpleOne.java");
assertFileAndExists( jdkfile );
long jdk5before = jdk5file.lastModified();
18 years, 1 month
Hibernate SVN: r10804 - branches/Branch_3_2/HibernateExt/tools/src/templates/pojo
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-14 08:07:25 -0500 (Tue, 14 Nov 2006)
New Revision: 10804
Added:
branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/GetPropertyAnnotation.ftl
Modified:
branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/PojoPropertyAccessors.ftl
Log:
allow users to add their own getter-annotations more easily.
Added: branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/GetPropertyAnnotation.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/GetPropertyAnnotation.ftl 2006-11-14 13:06:47 UTC (rev 10803)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/GetPropertyAnnotation.ftl 2006-11-14 13:07:25 UTC (rev 10804)
@@ -0,0 +1 @@
+<#include "Ejb3PropertyGetAnnotation.ftl"/>
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/PojoPropertyAccessors.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/PojoPropertyAccessors.ftl 2006-11-14 13:06:47 UTC (rev 10803)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/pojo/PojoPropertyAccessors.ftl 2006-11-14 13:07:25 UTC (rev 10804)
@@ -6,7 +6,7 @@
* ${pojo.getFieldJavaDoc(property, 4)}
*/
</#if>
- <#include "Ejb3PropertyGetAnnotation.ftl"/>
+ <#include "GetPropertyAnnotation.ftl"/>
${pojo.getPropertyGetModifiers(property)} ${pojo.getJavaTypeName(property, jdk5)} ${pojo.getGetterSignature(property)}() {
return this.${property.name};
}
18 years, 1 month
Hibernate SVN: r10803 - branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-11-14 08:06:47 -0500 (Tue, 14 Nov 2006)
New Revision: 10803
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
Log:
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java 2006-11-14 13:06:36 UTC (rev 10802)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java 2006-11-14 13:06:47 UTC (rev 10803)
@@ -176,6 +176,10 @@
return isCollection(property) && ((Collection)property.getValue()).isOneToMany();
}
+ public boolean isSimpleValue(Property property) {
+ return (property.getValue()!=null) && (property.getValue() instanceof SimpleValue);
+ }
+
public boolean isManyToOne(Property property) {
return (property.getValue()!=null) && (property.getValue() instanceof ManyToOne);
}
18 years, 1 month