Hibernate SVN: r10478 - trunk/HibernateExt/tools/doc/reference/en/modules
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2006-09-12 02:55:07 -0400 (Tue, 12 Sep 2006)
New Revision: 10478
Modified:
trunk/HibernateExt/tools/doc/reference/en/modules/reverseengineering.xml
Log:
doc being more explicit about catalog/schema
Modified: trunk/HibernateExt/tools/doc/reference/en/modules/reverseengineering.xml
===================================================================
--- trunk/HibernateExt/tools/doc/reference/en/modules/reverseengineering.xml 2006-09-08 21:01:51 UTC (rev 10477)
+++ trunk/HibernateExt/tools/doc/reference/en/modules/reverseengineering.xml 2006-09-12 06:55:07 UTC (rev 10478)
@@ -422,11 +422,11 @@
<calloutlist>
<callout arearefs="tablefilter-matchcatalog">
- <para>catalog (Optional): Catalog name for table</para>
+ <para>catalog (Optional): Catalog name for table. Has to be specified if you are reverse engineering multiple catalogs or if it is not equal to <literal>hiberante.default_catalog</literal></para>
</callout>
<callout arearefs="tablefilter-matchschema">
- <para>schema (Optional): Schema name for table</para>
+ <para>schema (Optional): Schema name for table. Has to be specified if you are reverse engineering multiple schemas or if it is not equal to <literal>hiberante.default_schema</literal></para>
</callout>
<callout arearefs="tablefilter-matchname">
18 years, 4 months
Hibernate SVN: r10477 - branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-09-08 17:01:51 -0400 (Fri, 08 Sep 2006)
New Revision: 10477
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/JDBCContext.java
Log:
lower trace, ignoring a tx join happens a lot in EJB 3
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/JDBCContext.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/JDBCContext.java 2006-09-08 21:00:48 UTC (rev 10476)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/JDBCContext.java 2006-09-08 21:01:51 UTC (rev 10477)
@@ -157,7 +157,7 @@
else {
try {
if ( !isTransactionInProgress() ) {
- log.debug( "TransactionFactory reported no active transaction; Synchronization not registered" );
+ log.trace( "TransactionFactory reported no active transaction; Synchronization not registered" );
return false;
}
else {
18 years, 4 months
Hibernate SVN: r10476 - trunk/Hibernate3/src/org/hibernate/jdbc
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2006-09-08 17:00:48 -0400 (Fri, 08 Sep 2006)
New Revision: 10476
Modified:
trunk/Hibernate3/src/org/hibernate/jdbc/JDBCContext.java
Log:
lower trace, ignoring a tx join happens a lot in EJB 3
Modified: trunk/Hibernate3/src/org/hibernate/jdbc/JDBCContext.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/jdbc/JDBCContext.java 2006-09-08 13:58:59 UTC (rev 10475)
+++ trunk/Hibernate3/src/org/hibernate/jdbc/JDBCContext.java 2006-09-08 21:00:48 UTC (rev 10476)
@@ -157,7 +157,7 @@
else {
try {
if ( !isTransactionInProgress() ) {
- log.debug( "TransactionFactory reported no active transaction; Synchronization not registered" );
+ log.trace( "TransactionFactory reported no active transaction; Synchronization not registered" );
return false;
}
else {
18 years, 4 months
Hibernate SVN: r10475 - in branches/Branch_3_2/Hibernate3/test/org/hibernate/test: . bytecode bytecode/cglib bytecode/javassist
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-08 09:58:59 -0400 (Fri, 08 Sep 2006)
New Revision: 10475
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/BytecodeSuite.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/Bean.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/Bean.java
Log:
HHH-1986 : InvocationTargetException on JavassistLazyInitializer
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java 2006-09-08 13:58:40 UTC (rev 10474)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/AllTests.java 2006-09-08 13:58:59 UTC (rev 10475)
@@ -4,7 +4,6 @@
import junit.framework.Test;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
-
import org.hibernate.dialect.Dialect;
import org.hibernate.test.abstractembeddedcomponents.cid.AbstractCompositeIdTest;
import org.hibernate.test.abstractembeddedcomponents.propertyref.AbstractComponentPropertyRefTest;
@@ -14,6 +13,7 @@
import org.hibernate.test.batchfetch.BatchFetchTest;
import org.hibernate.test.bidi.AuctionTest;
import org.hibernate.test.bidi.AuctionTest2;
+import org.hibernate.test.bytecode.BytecodeSuite;
import org.hibernate.test.cache.CacheSuite;
import org.hibernate.test.cascade.RefreshTest;
import org.hibernate.test.cid.CompositeIdTest;
@@ -126,11 +126,11 @@
import org.hibernate.test.unconstrained.UnconstrainedTest;
import org.hibernate.test.unidir.BackrefTest;
import org.hibernate.test.unionsubclass.UnionSubclassTest;
+import org.hibernate.test.util.UtilSuite;
import org.hibernate.test.version.VersionTest;
import org.hibernate.test.version.db.DbVersionTest;
import org.hibernate.test.version.sybase.SybaseTimestampVersioningTest;
import org.hibernate.test.where.WhereTest;
-import org.hibernate.test.util.UtilSuite;
/**
* @author Gavin King
@@ -286,8 +286,7 @@
suite.addTest( SequenceIdentityTest.suite() );
suite.addTest( InterceptorDynamicEntityTest.suite() );
suite.addTest( TuplizerDynamicEntityTest.suite() );
- suite.addTest( org.hibernate.test.bytecode.cglib.ReflectionOptimizerTest.suite() );
- suite.addTest( org.hibernate.test.bytecode.javassist.ReflectionOptimizerTest.suite() );
+ suite.addTest( BytecodeSuite.suite() );
suite.addTest( JPAComplianceSuite.suite() );
suite.addTest( AbstractComponentPropertyRefTest.suite() );
suite.addTest( AbstractCompositeIdTest.suite() );
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/Bean.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/Bean.hbm.xml 2006-09-08 13:58:40 UTC (rev 10474)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/Bean.hbm.xml 2006-09-08 13:58:59 UTC (rev 10475)
@@ -9,12 +9,12 @@
<id name="someString" type="string">
<generator class="assigned"/>
</id>
- <property name="someLong" type="long"/>
- <property name="someInteger" type="int"/>
- <property name="someDate" type="timestamp"/>
- <property name="somelong" type="long"/>
- <property name="someint" type="int"/>
- <property name="someObject" type="serializable"/>
+ <property name="someLong" type="long" column="S_LONG_1" />
+ <property name="someInteger" type="int" column="S_INT_1" />
+ <property name="someDate" type="timestamp" column="S_DATE_1" />
+ <property name="somelong" type="long" column="S_LONG_2" />
+ <property name="someint" type="int" column="S_INT_2" />
+ <property name="someObject" type="serializable" column="S_OBJ_1" />
</class>
</hibernate-mapping>
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/Bean.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/Bean.java 2006-09-08 13:58:40 UTC (rev 10474)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/Bean.java 2006-09-08 13:58:59 UTC (rev 10475)
@@ -1,6 +1,7 @@
package org.hibernate.test.bytecode;
import java.util.Date;
+import java.text.ParseException;
/**
* @author Steve Ebersole
@@ -70,4 +71,8 @@
public void setSomeObject(Object someObject) {
this.someObject = someObject;
}
+
+ public void throwException() throws ParseException {
+ throw new ParseException( "you asked for it...", 0 );
+ }
}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/BytecodeSuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/BytecodeSuite.java 2006-09-08 13:58:40 UTC (rev 10474)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/BytecodeSuite.java 2006-09-08 13:58:59 UTC (rev 10475)
@@ -0,0 +1,20 @@
+package org.hibernate.test.bytecode;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * todo: describe BytecodeSuite
+ *
+ * @author Steve Ebersole
+ */
+public class BytecodeSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "BytecodeProvider tests" );
+ suite.addTest( org.hibernate.test.bytecode.cglib.ReflectionOptimizerTest.suite() );
+ suite.addTest( org.hibernate.test.bytecode.cglib.InvocationTargetExceptionTest.suite() );
+ suite.addTest( org.hibernate.test.bytecode.javassist.ReflectionOptimizerTest.suite() );
+ suite.addTest( org.hibernate.test.bytecode.javassist.InvocationTargetExceptionTest.suite() );
+ return suite;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java 2006-09-08 13:58:40 UTC (rev 10474)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java 2006-09-08 13:58:59 UTC (rev 10475)
@@ -0,0 +1,64 @@
+package org.hibernate.test.bytecode.cglib;
+
+import org.hibernate.test.TestCase;
+import org.hibernate.test.bytecode.Bean;
+import org.hibernate.Session;
+import org.hibernate.Hibernate;
+import org.hibernate.cfg.Environment;
+import junit.framework.TestSuite;
+
+import java.text.ParseException;
+
+/**
+ * Test that the Javassist-based lazy initializer properly handles
+ * InvocationTargetExceptions
+ *
+ * @author Steve Ebersole
+ */
+public class InvocationTargetExceptionTest extends TestCase {
+ public InvocationTargetExceptionTest(String name) {
+ super( name );
+ }
+
+ protected String[] getMappings() {
+ return new String[] { "bytecode/Bean.hbm.xml" };
+ }
+
+ public static TestSuite suite() {
+ return new TestSuite( InvocationTargetExceptionTest.class );
+ }
+
+ public void testProxiedInvocationException() {
+ if ( ! ( Environment.getBytecodeProvider() instanceof org.hibernate.bytecode.cglib.BytecodeProviderImpl ) ) {
+ // because of the scoping :(
+ reportSkip( "env not configured for cglib provider", "bytecode-provider InvocationTargetException handling" );
+ return;
+ }
+ Session s = openSession();
+ s.beginTransaction();
+ Bean bean = new Bean();
+ bean.setSomeString( "my-bean" );
+ s.save( bean );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ bean = ( Bean ) s.load( Bean.class, bean.getSomeString() );
+ assertFalse( Hibernate.isInitialized( bean ) );
+ try {
+ bean.throwException();
+ fail( "exception not thrown" );
+ }
+ catch ( ParseException e ) {
+ // expected behavior
+ }
+ catch( Throwable t ) {
+ fail( "unexpected exception type : " + t );
+ }
+
+ s.delete( bean );
+ s.getTransaction().commit();
+ s.close();
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java 2006-09-08 13:58:40 UTC (rev 10474)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java 2006-09-08 13:58:59 UTC (rev 10475)
@@ -0,0 +1,65 @@
+package org.hibernate.test.bytecode.javassist;
+
+import org.hibernate.test.TestCase;
+import org.hibernate.test.bytecode.Bean;
+import org.hibernate.Session;
+import org.hibernate.Hibernate;
+import org.hibernate.cfg.Environment;
+
+import java.text.ParseException;
+
+import junit.framework.TestSuite;
+
+/**
+ * Test that the Javassist-based lazy initializer properly handles
+ * InvocationTargetExceptions
+ *
+ * @author Steve Ebersole
+ */
+public class InvocationTargetExceptionTest extends TestCase {
+ public InvocationTargetExceptionTest(String name) {
+ super( name );
+ }
+
+ protected String[] getMappings() {
+ return new String[] { "bytecode/Bean.hbm.xml" };
+ }
+
+ public static TestSuite suite() {
+ return new TestSuite( InvocationTargetExceptionTest.class );
+ }
+
+ public void testProxiedInvocationException() {
+ if ( ! ( Environment.getBytecodeProvider() instanceof org.hibernate.bytecode.javassist.BytecodeProviderImpl ) ) {
+ // because of the scoping :(
+ reportSkip( "env not configured for javassist provider", "bytecode-provider InvocationTargetException handling" );
+ return;
+ }
+ Session s = openSession();
+ s.beginTransaction();
+ Bean bean = new Bean();
+ bean.setSomeString( "my-bean" );
+ s.save( bean );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ bean = ( Bean ) s.load( Bean.class, bean.getSomeString() );
+ assertFalse( Hibernate.isInitialized( bean ) );
+ try {
+ bean.throwException();
+ fail( "exception not thrown" );
+ }
+ catch ( ParseException e ) {
+ // expected behavior
+ }
+ catch( Throwable t ) {
+ fail( "unexpected exception type : " + t );
+ }
+
+ s.delete( bean );
+ s.getTransaction().commit();
+ s.close();
+ }
+}
18 years, 4 months
Hibernate SVN: r10474 - branches/Branch_3_2/Hibernate3/src/org/hibernate/proxy/pojo/javassist
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-08 09:58:40 -0400 (Fri, 08 Sep 2006)
New Revision: 10474
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java
Log:
HHH-1986 : InvocationTargetException on JavassistLazyInitializer
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java 2006-09-08 13:57:48 UTC (rev 10473)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java 2006-09-08 13:58:40 UTC (rev 10474)
@@ -182,8 +182,10 @@
}
public Object invoke(
- final Object proxy, final Method thisMethod,
- final Method proceed, final Object[] args) throws Exception {
+ final Object proxy,
+ final Method thisMethod,
+ final Method proceed,
+ final Object[] args) throws Throwable {
if ( this.constructed ) {
Object result;
try {
@@ -195,30 +197,24 @@
if ( result == INVOKE_IMPLEMENTATION ) {
Object target = getImplementation();
final Object returnValue;
- if ( ReflectHelper.isPublic( persistentClass, thisMethod ) ) {
- if ( !isCastable(
- target.getClass(), thisMethod
- .getDeclaringClass()
- ) ) {
- throw new ClassCastException(
- target.getClass()
- .getName()
- );
- }
- returnValue = thisMethod.invoke( target, args );
- }
- else {
- if ( !thisMethod.isAccessible() ) {
- thisMethod.setAccessible( true );
- }
- try {
- returnValue = thisMethod.invoke( target, args );
- }
- catch ( InvocationTargetException e ) {
- throw new Exception( e.getTargetException().getCause() );
- }
- }
- return returnValue == target ? proxy : returnValue;
+ try {
+ if ( ReflectHelper.isPublic( persistentClass, thisMethod ) ) {
+ if ( !isCastable( target.getClass(), thisMethod.getDeclaringClass()) ) {
+ throw new ClassCastException( target.getClass().getName() );
+ }
+ returnValue = thisMethod.invoke( target, args );
+ }
+ else {
+ if ( !thisMethod.isAccessible() ) {
+ thisMethod.setAccessible( true );
+ }
+ returnValue = thisMethod.invoke( target, args );
+ }
+ return returnValue == target ? proxy : returnValue;
+ }
+ catch ( InvocationTargetException ite ) {
+ throw ite.getTargetException();
+ }
}
else {
return result;
18 years, 4 months
Hibernate SVN: r10473 - trunk/Hibernate3/test/org/hibernate/test
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-08 09:57:48 -0400 (Fri, 08 Sep 2006)
New Revision: 10473
Modified:
trunk/Hibernate3/test/org/hibernate/test/AllTests.java
Log:
HHH-1986 : InvocationTargetException on JavassistLazyInitializer
Modified: trunk/Hibernate3/test/org/hibernate/test/AllTests.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/AllTests.java 2006-09-08 13:55:33 UTC (rev 10472)
+++ trunk/Hibernate3/test/org/hibernate/test/AllTests.java 2006-09-08 13:57:48 UTC (rev 10473)
@@ -4,13 +4,16 @@
import junit.framework.Test;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
-
+import org.hibernate.dialect.Dialect;
+import org.hibernate.test.abstractembeddedcomponents.cid.AbstractCompositeIdTest;
+import org.hibernate.test.abstractembeddedcomponents.propertyref.AbstractComponentPropertyRefTest;
import org.hibernate.test.array.ArrayTest;
import org.hibernate.test.ast.ASTIteratorTest;
import org.hibernate.test.ast.ASTUtilTest;
import org.hibernate.test.batchfetch.BatchFetchTest;
import org.hibernate.test.bidi.AuctionTest;
import org.hibernate.test.bidi.AuctionTest2;
+import org.hibernate.test.bytecode.BytecodeSuite;
import org.hibernate.test.cache.CacheSuite;
import org.hibernate.test.cascade.RefreshTest;
import org.hibernate.test.cid.CompositeIdTest;
@@ -54,6 +57,7 @@
import org.hibernate.test.join.JoinTest;
import org.hibernate.test.joinedsubclass.JoinedSubclassTest;
import org.hibernate.test.joinfetch.JoinFetchTest;
+import org.hibernate.test.jpa.JPAComplianceSuite;
import org.hibernate.test.lazycache.InstrumentCacheTest;
import org.hibernate.test.lazycache.InstrumentCacheTest2;
import org.hibernate.test.lazyonetoone.LazyOneToOneTest;
@@ -104,6 +108,7 @@
import org.hibernate.test.readonly.ReadOnlyTest;
import org.hibernate.test.rowid.RowIdTest;
import org.hibernate.test.sorted.SortTest;
+import org.hibernate.test.sql.NativeSqlSupportSuite;
import org.hibernate.test.stats.SessionStatsTest;
import org.hibernate.test.stats.StatsTest;
import org.hibernate.test.subclassfilter.DiscrimSubclassFilterTest;
@@ -121,16 +126,11 @@
import org.hibernate.test.unconstrained.UnconstrainedTest;
import org.hibernate.test.unidir.BackrefTest;
import org.hibernate.test.unionsubclass.UnionSubclassTest;
+import org.hibernate.test.util.UtilSuite;
import org.hibernate.test.version.VersionTest;
import org.hibernate.test.version.db.DbVersionTest;
import org.hibernate.test.version.sybase.SybaseTimestampVersioningTest;
import org.hibernate.test.where.WhereTest;
-import org.hibernate.test.abstractembeddedcomponents.propertyref.AbstractComponentPropertyRefTest;
-import org.hibernate.test.abstractembeddedcomponents.cid.AbstractCompositeIdTest;
-import org.hibernate.test.jpa.JPAComplianceSuite;
-import org.hibernate.test.util.UtilSuite;
-import org.hibernate.test.sql.NativeSqlSupportSuite;
-import org.hibernate.dialect.Dialect;
/**
* @author Gavin King
@@ -286,8 +286,7 @@
suite.addTest( SequenceIdentityTest.suite() );
suite.addTest( InterceptorDynamicEntityTest.suite() );
suite.addTest( TuplizerDynamicEntityTest.suite() );
- suite.addTest( org.hibernate.test.bytecode.cglib.ReflectionOptimizerTest.suite() );
- suite.addTest( org.hibernate.test.bytecode.javassist.ReflectionOptimizerTest.suite() );
+ suite.addTest( BytecodeSuite.suite() );
suite.addTest( JPAComplianceSuite.suite() );
suite.addTest( AbstractComponentPropertyRefTest.suite() );
suite.addTest( AbstractCompositeIdTest.suite() );
18 years, 4 months
Hibernate SVN: r10472 - in trunk/Hibernate3/test/org/hibernate/test/bytecode: . cglib javassist
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-08 09:55:33 -0400 (Fri, 08 Sep 2006)
New Revision: 10472
Added:
trunk/Hibernate3/test/org/hibernate/test/bytecode/BytecodeSuite.java
trunk/Hibernate3/test/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java
trunk/Hibernate3/test/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java
Modified:
trunk/Hibernate3/test/org/hibernate/test/bytecode/Bean.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/bytecode/Bean.java
Log:
HHH-1986 : InvocationTargetException on JavassistLazyInitializer
Modified: trunk/Hibernate3/test/org/hibernate/test/bytecode/Bean.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/bytecode/Bean.hbm.xml 2006-09-08 13:55:13 UTC (rev 10471)
+++ trunk/Hibernate3/test/org/hibernate/test/bytecode/Bean.hbm.xml 2006-09-08 13:55:33 UTC (rev 10472)
@@ -9,12 +9,12 @@
<id name="someString" type="string">
<generator class="assigned"/>
</id>
- <property name="someLong" type="long"/>
- <property name="someInteger" type="int"/>
- <property name="someDate" type="timestamp"/>
- <property name="somelong" type="long"/>
- <property name="someint" type="int"/>
- <property name="someObject" type="serializable"/>
+ <property name="someLong" type="long" column="S_LONG_1" />
+ <property name="someInteger" type="int" column="S_INT_1" />
+ <property name="someDate" type="timestamp" column="S_DATE_1" />
+ <property name="somelong" type="long" column="S_LONG_2" />
+ <property name="someint" type="int" column="S_INT_2" />
+ <property name="someObject" type="serializable" column="S_OBJ_1" />
</class>
</hibernate-mapping>
Modified: trunk/Hibernate3/test/org/hibernate/test/bytecode/Bean.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/bytecode/Bean.java 2006-09-08 13:55:13 UTC (rev 10471)
+++ trunk/Hibernate3/test/org/hibernate/test/bytecode/Bean.java 2006-09-08 13:55:33 UTC (rev 10472)
@@ -1,6 +1,7 @@
package org.hibernate.test.bytecode;
import java.util.Date;
+import java.text.ParseException;
/**
* @author Steve Ebersole
@@ -70,4 +71,8 @@
public void setSomeObject(Object someObject) {
this.someObject = someObject;
}
+
+ public void throwException() throws ParseException {
+ throw new ParseException( "you asked for it...", 0 );
+ }
}
Added: trunk/Hibernate3/test/org/hibernate/test/bytecode/BytecodeSuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/bytecode/BytecodeSuite.java 2006-09-08 13:55:13 UTC (rev 10471)
+++ trunk/Hibernate3/test/org/hibernate/test/bytecode/BytecodeSuite.java 2006-09-08 13:55:33 UTC (rev 10472)
@@ -0,0 +1,20 @@
+package org.hibernate.test.bytecode;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * todo: describe BytecodeSuite
+ *
+ * @author Steve Ebersole
+ */
+public class BytecodeSuite {
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "BytecodeProvider tests" );
+ suite.addTest( org.hibernate.test.bytecode.cglib.ReflectionOptimizerTest.suite() );
+ suite.addTest( org.hibernate.test.bytecode.cglib.InvocationTargetExceptionTest.suite() );
+ suite.addTest( org.hibernate.test.bytecode.javassist.ReflectionOptimizerTest.suite() );
+ suite.addTest( org.hibernate.test.bytecode.javassist.InvocationTargetExceptionTest.suite() );
+ return suite;
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java 2006-09-08 13:55:13 UTC (rev 10471)
+++ trunk/Hibernate3/test/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java 2006-09-08 13:55:33 UTC (rev 10472)
@@ -0,0 +1,64 @@
+package org.hibernate.test.bytecode.cglib;
+
+import org.hibernate.test.TestCase;
+import org.hibernate.test.bytecode.Bean;
+import org.hibernate.Session;
+import org.hibernate.Hibernate;
+import org.hibernate.cfg.Environment;
+import junit.framework.TestSuite;
+
+import java.text.ParseException;
+
+/**
+ * Test that the Javassist-based lazy initializer properly handles
+ * InvocationTargetExceptions
+ *
+ * @author Steve Ebersole
+ */
+public class InvocationTargetExceptionTest extends TestCase {
+ public InvocationTargetExceptionTest(String name) {
+ super( name );
+ }
+
+ protected String[] getMappings() {
+ return new String[] { "bytecode/Bean.hbm.xml" };
+ }
+
+ public static TestSuite suite() {
+ return new TestSuite( InvocationTargetExceptionTest.class );
+ }
+
+ public void testProxiedInvocationException() {
+ if ( ! ( Environment.getBytecodeProvider() instanceof org.hibernate.bytecode.cglib.BytecodeProviderImpl ) ) {
+ // because of the scoping :(
+ reportSkip( "env not configured for cglib provider", "bytecode-provider InvocationTargetException handling" );
+ return;
+ }
+ Session s = openSession();
+ s.beginTransaction();
+ Bean bean = new Bean();
+ bean.setSomeString( "my-bean" );
+ s.save( bean );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ bean = ( Bean ) s.load( Bean.class, bean.getSomeString() );
+ assertFalse( Hibernate.isInitialized( bean ) );
+ try {
+ bean.throwException();
+ fail( "exception not thrown" );
+ }
+ catch ( ParseException e ) {
+ // expected behavior
+ }
+ catch( Throwable t ) {
+ fail( "unexpected exception type : " + t );
+ }
+
+ s.delete( bean );
+ s.getTransaction().commit();
+ s.close();
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java 2006-09-08 13:55:13 UTC (rev 10471)
+++ trunk/Hibernate3/test/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java 2006-09-08 13:55:33 UTC (rev 10472)
@@ -0,0 +1,65 @@
+package org.hibernate.test.bytecode.javassist;
+
+import org.hibernate.test.TestCase;
+import org.hibernate.test.bytecode.Bean;
+import org.hibernate.Session;
+import org.hibernate.Hibernate;
+import org.hibernate.cfg.Environment;
+
+import java.text.ParseException;
+
+import junit.framework.TestSuite;
+
+/**
+ * Test that the Javassist-based lazy initializer properly handles
+ * InvocationTargetExceptions
+ *
+ * @author Steve Ebersole
+ */
+public class InvocationTargetExceptionTest extends TestCase {
+ public InvocationTargetExceptionTest(String name) {
+ super( name );
+ }
+
+ protected String[] getMappings() {
+ return new String[] { "bytecode/Bean.hbm.xml" };
+ }
+
+ public static TestSuite suite() {
+ return new TestSuite( InvocationTargetExceptionTest.class );
+ }
+
+ public void testProxiedInvocationException() {
+ if ( ! ( Environment.getBytecodeProvider() instanceof org.hibernate.bytecode.javassist.BytecodeProviderImpl ) ) {
+ // because of the scoping :(
+ reportSkip( "env not configured for javassist provider", "bytecode-provider InvocationTargetException handling" );
+ return;
+ }
+ Session s = openSession();
+ s.beginTransaction();
+ Bean bean = new Bean();
+ bean.setSomeString( "my-bean" );
+ s.save( bean );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ bean = ( Bean ) s.load( Bean.class, bean.getSomeString() );
+ assertFalse( Hibernate.isInitialized( bean ) );
+ try {
+ bean.throwException();
+ fail( "exception not thrown" );
+ }
+ catch ( ParseException e ) {
+ // expected behavior
+ }
+ catch( Throwable t ) {
+ fail( "unexpected exception type : " + t );
+ }
+
+ s.delete( bean );
+ s.getTransaction().commit();
+ s.close();
+ }
+}
18 years, 4 months
Hibernate SVN: r10471 - trunk/Hibernate3/src/org/hibernate/proxy/pojo/javassist
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-08 09:55:13 -0400 (Fri, 08 Sep 2006)
New Revision: 10471
Modified:
trunk/Hibernate3/src/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java
Log:
HHH-1986 : InvocationTargetException on JavassistLazyInitializer
Modified: trunk/Hibernate3/src/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java 2006-09-08 12:53:06 UTC (rev 10470)
+++ trunk/Hibernate3/src/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java 2006-09-08 13:55:13 UTC (rev 10471)
@@ -182,8 +182,10 @@
}
public Object invoke(
- final Object proxy, final Method thisMethod,
- final Method proceed, final Object[] args) throws Exception {
+ final Object proxy,
+ final Method thisMethod,
+ final Method proceed,
+ final Object[] args) throws Throwable {
if ( this.constructed ) {
Object result;
try {
@@ -195,30 +197,24 @@
if ( result == INVOKE_IMPLEMENTATION ) {
Object target = getImplementation();
final Object returnValue;
- if ( ReflectHelper.isPublic( persistentClass, thisMethod ) ) {
- if ( !isCastable(
- target.getClass(), thisMethod
- .getDeclaringClass()
- ) ) {
- throw new ClassCastException(
- target.getClass()
- .getName()
- );
- }
- returnValue = thisMethod.invoke( target, args );
- }
- else {
- if ( !thisMethod.isAccessible() ) {
- thisMethod.setAccessible( true );
- }
- try {
- returnValue = thisMethod.invoke( target, args );
- }
- catch ( InvocationTargetException e ) {
- throw new Exception( e.getTargetException().getCause() );
- }
- }
- return returnValue == target ? proxy : returnValue;
+ try {
+ if ( ReflectHelper.isPublic( persistentClass, thisMethod ) ) {
+ if ( !isCastable( target.getClass(), thisMethod.getDeclaringClass()) ) {
+ throw new ClassCastException( target.getClass().getName() );
+ }
+ returnValue = thisMethod.invoke( target, args );
+ }
+ else {
+ if ( !thisMethod.isAccessible() ) {
+ thisMethod.setAccessible( true );
+ }
+ returnValue = thisMethod.invoke( target, args );
+ }
+ return returnValue == target ? proxy : returnValue;
+ }
+ catch ( InvocationTargetException ite ) {
+ throw ite.getTargetException();
+ }
}
else {
return result;
18 years, 4 months
Hibernate SVN: r10470 - trunk/Hibernate3/src/org/hibernate/collection
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-08 08:53:06 -0400 (Fri, 08 Sep 2006)
New Revision: 10470
Modified:
trunk/Hibernate3/src/org/hibernate/collection/PersistentMap.java
trunk/Hibernate3/src/org/hibernate/collection/PersistentSet.java
Log:
formatting
Modified: trunk/Hibernate3/src/org/hibernate/collection/PersistentMap.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/collection/PersistentMap.java 2006-09-08 12:23:18 UTC (rev 10469)
+++ trunk/Hibernate3/src/org/hibernate/collection/PersistentMap.java 2006-09-08 12:53:06 UTC (rev 10470)
@@ -31,6 +31,39 @@
protected Map map;
+ /**
+ * Empty constructor.
+ * <p/>
+ * Note: this form is not ever ever ever used by Hibernate; it is, however,
+ * needed for SOAP libraries and other such marshalling code.
+ */
+ public PersistentMap() {
+ // intentionally empty
+ }
+
+ /**
+ * Instantiates a lazy map (the underlying map is un-initialized).
+ *
+ * @param session The session to which this map will belong.
+ */
+ public PersistentMap(SessionImplementor session) {
+ super(session);
+ }
+
+ /**
+ * Instantiates a non-lazy map (the underlying map is constructed
+ * from the incoming map reference).
+ *
+ * @param session The session to which this map will belong.
+ * @param map The underlying map data.
+ */
+ public PersistentMap(SessionImplementor session, Map map) {
+ super(session);
+ this.map = map;
+ setInitialized();
+ setDirectlyAccessible(true);
+ }
+
public Serializable getSnapshot(CollectionPersister persister) throws HibernateException {
EntityMode entityMode = getSession().getEntityMode();
HashMap clonedMap = new HashMap( map.size() );
@@ -68,23 +101,11 @@
public boolean isWrapper(Object collection) {
return map==collection;
}
-
- public PersistentMap(SessionImplementor session) {
- super(session);
- }
- public PersistentMap() {} //needed for SOAP libraries, etc
-
public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {
this.map = ( Map ) persister.getCollectionType().instantiate( anticipatedSize );
}
- public PersistentMap(SessionImplementor session, Map map) {
- super(session);
- this.map = map;
- setInitialized();
- setDirectlyAccessible(true);
- }
/**
* @see java.util.Map#size()
@@ -130,14 +151,21 @@
* @see java.util.Map#put(Object, Object)
*/
public Object put(Object key, Object value) {
- Object old = isPutQueueEnabled() ?
- readElementByIndex(key) : UNKNOWN;
- if ( old==UNKNOWN ) {
- write();
- return map.put(key, value);
+ if ( isPutQueueEnabled() ) {
+ Object old = readElementByIndex( key );
+ queueOperation( new Put( key, value, old ) );
+ return old;
}
else {
- queueOperation( new Put(key, value, old) );
+ initialize( true );
+ Object old = map.put( key, value );
+ // would be better to use the element-type to determine
+ // whether the old and the new are equal here; the problem being
+ // we do not necessarily have access to the element type in all
+ // cases
+ if ( value != old ) {
+ dirty();
+ }
return old;
}
}
@@ -146,15 +174,18 @@
* @see java.util.Map#remove(Object)
*/
public Object remove(Object key) {
- Object old = isPutQueueEnabled() ?
- readElementByIndex(key) : UNKNOWN;
- if ( old==UNKNOWN ) {
- write();
- return map.remove(key);
+ if ( isPutQueueEnabled() ) {
+ Object old = readElementByIndex( key );
+ queueOperation( new Remove( key, old ) );
+ return old;
}
else {
- queueOperation( new Remove(key, old) );
- return old;
+ // TODO : safe to interpret "map.remove(key) == null" as non-dirty?
+ initialize( true );
+ if ( map.containsKey( key ) ) {
+ dirty();
+ }
+ return map.remove( key );
}
}
@@ -163,8 +194,12 @@
*/
public void putAll(Map puts) {
if ( puts.size()>0 ) {
- write();
- map.putAll(puts);
+ initialize( true );
+ Iterator itr = puts.entrySet().iterator();
+ while ( itr.hasNext() ) {
+ Map.Entry entry = ( Entry ) itr.next();
+ put( entry.getKey(), entry.getValue() );
+ }
}
}
@@ -176,8 +211,11 @@
queueOperation( new Clear() );
}
else {
- write();
- map.clear();
+ initialize( true );
+ if ( ! map.isEmpty() ) {
+ dirty();
+ map.clear();
+ }
}
}
Modified: trunk/Hibernate3/src/org/hibernate/collection/PersistentSet.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/collection/PersistentSet.java 2006-09-08 12:23:18 UTC (rev 10469)
+++ trunk/Hibernate3/src/org/hibernate/collection/PersistentSet.java 2006-09-08 12:53:06 UTC (rev 10470)
@@ -31,6 +31,45 @@
protected Set set;
protected transient List tempList;
+ /**
+ * Empty constructor.
+ * <p/>
+ * Note: this form is not ever ever ever used by Hibernate; it is, however,
+ * needed for SOAP libraries and other such marshalling code.
+ */
+ public PersistentSet() {
+ // intentionally empty
+ }
+
+ /**
+ * Constructor matching super. Instantiates a lazy set (the underlying
+ * set is un-initialized).
+ *
+ * @param session The session to which this set will belong.
+ */
+ public PersistentSet(SessionImplementor session) {
+ super( session );
+ }
+
+ /**
+ * Instantiates a non-lazy set (the underlying set is constructed
+ * from the incoming set reference).
+ *
+ * @param session The session to which this set will belong.
+ * @param set The underlying set data.
+ */
+ public PersistentSet(SessionImplementor session, java.util.Set set) {
+ super(session);
+ // Sets can be just a view of a part of another collection.
+ // do we need to copy it to be sure it won't be changing
+ // underneath us?
+ // ie. this.set.addAll(set);
+ this.set = set;
+ setInitialized();
+ setDirectlyAccessible(true);
+ }
+
+
public Serializable getSnapshot(CollectionPersister persister)
throws HibernateException {
EntityMode entityMode = getSession().getEntityMode();
@@ -71,27 +110,10 @@
public boolean isSnapshotEmpty(Serializable snapshot) {
return ( (java.util.Map) snapshot ).isEmpty();
}
-
- public PersistentSet(SessionImplementor session) {
- super(session);
- }
- public PersistentSet() {} //needed for SOAP libraries, etc
-
public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {
this.set = ( Set ) persister.getCollectionType().instantiate( anticipatedSize );
}
-
- public PersistentSet(SessionImplementor session, java.util.Set set) {
- super(session);
- // Sets can be just a view of a part of another collection.
- // do we need to copy it to be sure it won't be changing
- // underneath us?
- // ie. this.set.addAll(set);
- this.set = set;
- setInitialized();
- setDirectlyAccessible(true);
- }
public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
throws HibernateException {
@@ -162,11 +184,16 @@
* @see java.util.Set#add(Object)
*/
public boolean add(Object value) {
- Boolean exists = isOperationQueueEnabled() ?
- readElementExistence(value) : null;
- if (exists==null) {
- write();
- return set.add(value);
+ Boolean exists = isOperationQueueEnabled() ? readElementExistence( value ) : null;
+ if ( exists == null ) {
+ initialize( true );
+ if ( set.add( value ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
}
else if ( exists.booleanValue() ) {
return false;
@@ -181,11 +208,16 @@
* @see java.util.Set#remove(Object)
*/
public boolean remove(Object value) {
- Boolean exists = isPutQueueEnabled() ?
- readElementExistence(value) : null;
+ Boolean exists = isPutQueueEnabled() ? readElementExistence( value ) : null;
if ( exists==null ) {
- write();
- return set.remove(value);
+ initialize( true );
+ if ( set.remove( value ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
}
else if ( exists.booleanValue() ) {
queueOperation( new SimpleRemove(value) );
@@ -208,9 +240,15 @@
* @see java.util.Set#addAll(Collection)
*/
public boolean addAll(Collection coll) {
- if ( coll.size()> 0 ) {
- write();
- return set.addAll(coll);
+ if ( coll.size() > 0 ) {
+ initialize( true );
+ if ( set.addAll( coll ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
}
else {
return false;
@@ -221,17 +259,29 @@
* @see java.util.Set#retainAll(Collection)
*/
public boolean retainAll(Collection coll) {
- write();
- return set.retainAll(coll);
+ initialize( true );
+ if ( set.addAll( coll ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
}
/**
* @see java.util.Set#removeAll(Collection)
*/
public boolean removeAll(Collection coll) {
- if ( coll.size()>0 ) {
- write();
- return set.removeAll(coll);
+ if ( coll.size() > 0 ) {
+ initialize( true );
+ if ( set.removeAll( coll ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
}
else {
return false;
@@ -246,8 +296,11 @@
queueOperation( new Clear() );
}
else {
- write();
- set.clear();
+ initialize( true );
+ if ( !set.isEmpty() ) {
+ set.clear();
+ dirty();
+ }
}
}
18 years, 4 months
Hibernate SVN: r10469 - trunk/Hibernate3/src/org/hibernate
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-08 08:23:18 -0400 (Fri, 08 Sep 2006)
New Revision: 10469
Modified:
trunk/Hibernate3/src/org/hibernate/FlushMode.java
Log:
HHH-2042 : FlushMode javadoc
Modified: trunk/Hibernate3/src/org/hibernate/FlushMode.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/FlushMode.java 2006-09-08 12:23:08 UTC (rev 10468)
+++ trunk/Hibernate3/src/org/hibernate/FlushMode.java 2006-09-08 12:23:18 UTC (rev 10469)
@@ -11,6 +11,9 @@
* and executing SQL statements.
*
* @see Session#setFlushMode(FlushMode)
+ * @see Query#setFlushMode(FlushMode)
+ * @see Criteria#setFlushMode(FlushMode)
+ *
* @author Gavin King
*/
public final class FlushMode implements Serializable {
@@ -23,12 +26,13 @@
this.level = level;
this.name = name;
}
+
public String toString() {
return name;
}
/**
- * The <tt>Session</tt> is never flushed unless <tt>flush()</tt>
+ * The {@link Session} is never flushed unless {@link Session#flush}
* is explicitly called by the application. This mode is very
* efficient for read only transactions.
*
@@ -37,27 +41,27 @@
public static final FlushMode NEVER = new FlushMode( 0, "NEVER" );
/**
- * The <tt>Session</tt> is onyl eve flushed when <tt>flush()</tt>
+ * The {@link Session} is only ever flushed when {@link Session#flush}
* is explicitly called by the application. This mode is very
* efficient for read only transactions.
*/
public static final FlushMode MANUAL = new FlushMode( 0, "MANUAL" );
/**
- * The <tt>Session</tt> is flushed when <tt>Transaction.commit()</tt>
+ * The {@link Session} is flushed when {@link Transaction#commit}
* is called.
*/
public static final FlushMode COMMIT = new FlushMode(5, "COMMIT");
/**
- * The <tt>Session</tt> is sometimes flushed before query execution
+ * The {@link Session} is sometimes flushed before query execution
* in order to ensure that queries never return stale state. This
* is the default flush mode.
*/
public static final FlushMode AUTO = new FlushMode(10, "AUTO");
/**
- * The <tt>Session</tt> is flushed before every query. This is
+ * The {@link Session} is flushed before every query. This is
* almost always unnecessary and inefficient.
*/
public static final FlushMode ALWAYS = new FlushMode(20, "ALWAYS");
@@ -86,9 +90,3 @@
return ( FlushMode ) INSTANCES.get( name );
}
}
-
-
-
-
-
-
18 years, 4 months