Hibernate SVN: r11338 - branches/Branch_3_2/Hibernate3/src/org/hibernate/impl.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-03-22 18:43:13 -0400 (Thu, 22 Mar 2007)
New Revision: 11338
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/SessionFactoryObjectFactory.java
Log:
HHH-2513 move lookup failure from WARN to DEBUG, it's catch up by the caller anyway
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/SessionFactoryObjectFactory.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/SessionFactoryObjectFactory.java 2007-03-22 22:42:58 UTC (rev 11337)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/SessionFactoryObjectFactory.java 2007-03-22 22:43:13 UTC (rev 11338)
@@ -135,7 +135,7 @@
log.debug("lookup: name=" + name);
Object result = NAMED_INSTANCES.get(name);
if (result==null) {
- log.warn("Not found: " + name);
+ log.debug("Not found: " + name);
log.debug(NAMED_INSTANCES);
}
return result;
@@ -145,7 +145,7 @@
log.debug("lookup: uid=" + uid);
Object result = INSTANCES.get(uid);
if (result==null) {
- log.warn("Not found: " + uid);
+ log.debug("Not found: " + uid);
log.debug(INSTANCES);
}
return result;
17 years, 1 month
Hibernate SVN: r11337 - trunk/Hibernate3/src/org/hibernate/impl.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-03-22 18:42:58 -0400 (Thu, 22 Mar 2007)
New Revision: 11337
Modified:
trunk/Hibernate3/src/org/hibernate/impl/SessionFactoryObjectFactory.java
Log:
HHH-2513 move lookup failure from WARN to DEBUG, it's catch up by the caller anyway
Modified: trunk/Hibernate3/src/org/hibernate/impl/SessionFactoryObjectFactory.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/impl/SessionFactoryObjectFactory.java 2007-03-22 21:08:24 UTC (rev 11336)
+++ trunk/Hibernate3/src/org/hibernate/impl/SessionFactoryObjectFactory.java 2007-03-22 22:42:58 UTC (rev 11337)
@@ -135,7 +135,7 @@
log.debug("lookup: name=" + name);
Object result = NAMED_INSTANCES.get(name);
if (result==null) {
- log.warn("Not found: " + name);
+ log.debug("Not found: " + name);
log.debug(NAMED_INSTANCES);
}
return result;
@@ -145,7 +145,7 @@
log.debug("lookup: uid=" + uid);
Object result = INSTANCES.get(uid);
if (result==null) {
- log.warn("Not found: " + uid);
+ log.debug("Not found: " + uid);
log.debug(INSTANCES);
}
return result;
17 years, 1 month
Hibernate SVN: r11336 - trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/xml.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-03-22 17:08:24 -0400 (Thu, 22 Mar 2007)
New Revision: 11336
Added:
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/xml/CounterListener.java
Modified:
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/xml/XmlAttributeOverrideTest.java
trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/xml/orm3.xml
Log:
EJB-279 tests on default entity listeners
Added: trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/xml/CounterListener.java
===================================================================
--- trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/xml/CounterListener.java (rev 0)
+++ trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/xml/CounterListener.java 2007-03-22 21:08:24 UTC (rev 11336)
@@ -0,0 +1,36 @@
+//$Id: $
+package org.hibernate.ejb.test.xml;
+
+import javax.persistence.PrePersist;
+import javax.persistence.PreUpdate;
+import javax.persistence.PreRemove;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class CounterListener {
+ public static int insert;
+ public static int update;
+ public static int delete;
+
+ @PrePersist
+ public void increaseInsert(Object object) {
+ insert++;
+ }
+
+ @PreUpdate
+ public void increaseUpdate(Object object) {
+ update++;
+ }
+
+ @PreRemove
+ public void increaseDelete(Object object) {
+ delete++;
+ }
+
+ public static void reset() {
+ insert = 0;
+ update = 0;
+ delete = 0;
+ }
+}
Modified: trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/xml/XmlAttributeOverrideTest.java
===================================================================
--- trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/xml/XmlAttributeOverrideTest.java 2007-03-22 17:37:37 UTC (rev 11335)
+++ trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/xml/XmlAttributeOverrideTest.java 2007-03-22 21:08:24 UTC (rev 11336)
@@ -28,6 +28,43 @@
em.close();
}
+ public void testDefaultEventListener() throws Exception {
+ EntityManager em = factory.createEntityManager();
+ em.getTransaction().begin();
+
+ CounterListener.reset();
+
+ Employee e = new Employee();
+ e.setId(Long.valueOf(100));
+ e.setName("Bubba");
+ e.setHomeAddress(new Address("123 Main St", "New York", "NY", "11111"));
+ e.setMailAddress(new Address("P.O. Box 123", "New York", "NY", "11111"));
+
+ em.persist(e);
+
+ em.flush();
+
+ em.clear();
+
+ em.find( Employee.class, e.getId() ).setName( "Bibo" );
+
+ em.flush();
+
+ em.clear();
+
+ em.remove( em.find( Employee.class, e.getId() ) );
+
+ em.flush();
+
+
+ em.getTransaction().rollback();
+ em.close();
+
+ assertEquals( 1, CounterListener.insert );
+ assertEquals( 1, CounterListener.update );
+ assertEquals( 1, CounterListener.delete );
+ }
+
public Class[] getAnnotatedClasses() {
return new Class[0];
}
Modified: trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/xml/orm3.xml
===================================================================
--- trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/xml/orm3.xml 2007-03-22 17:37:37 UTC (rev 11335)
+++ trunk/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/xml/orm3.xml 2007-03-22 21:08:24 UTC (rev 11336)
@@ -5,6 +5,14 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
version="1.0">
+ <persistence-unit-metadata>
+ <persistence-unit-defaults>
+ <entity-listeners>
+ <entity-listener class="org.hibernate.ejb.test.xml.CounterListener"/>
+ </entity-listeners>
+ </persistence-unit-defaults>
+ </persistence-unit-metadata>
+
<entity class="org.hibernate.ejb.test.xml.Employee" metadata-complete="false" access="FIELD">
<attributes>
<id name="id"/>
17 years, 1 month
Hibernate SVN: r11335 - trunk/Hibernate3/test/org/hibernate/test/keymanytoone/bidir/component.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-03-22 13:37:37 -0400 (Thu, 22 Mar 2007)
New Revision: 11335
Modified:
trunk/Hibernate3/test/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java
Log:
HHH-2277 : key-many-to-one (bidir + eager) : test
Modified: trunk/Hibernate3/test/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java 2007-03-22 17:36:43 UTC (rev 11334)
+++ trunk/Hibernate3/test/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java 2007-03-22 17:37:37 UTC (rev 11335)
@@ -3,6 +3,10 @@
import junit.framework.Test;
import org.hibernate.Session;
+import org.hibernate.HibernateException;
+import org.hibernate.event.def.DefaultLoadEventListener;
+import org.hibernate.event.LoadEvent;
+import org.hibernate.event.LoadEventListener;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
@@ -12,6 +16,7 @@
* @author Steve Ebersole
*/
public class EagerKeyManyToOneTest extends TestCase {
+
public EagerKeyManyToOneTest(String name) {
super( name );
}
@@ -27,6 +32,12 @@
protected void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ LoadEventListener[] baseListeners = cfg.getEventListeners().getLoadEventListeners();
+ int baseLength = baseListeners.length;
+ LoadEventListener[] expandedListeners = new LoadEventListener[ baseLength + 1 ];
+ expandedListeners[ 0 ] = new CustomLoadListener();
+ System.arraycopy( baseListeners, 0, expandedListeners, 1, baseLength );
+ cfg.getEventListeners().setLoadEventListeners( expandedListeners );
}
public void testSaveCascadedToKeyManyToOne() {
@@ -62,6 +73,8 @@
// essentially we have a bidirectional association where one side of the
// association is actually part of a composite PK
//
+// See #testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelfFailureExpected() below...
+//
// The way these are mapped causes the problem because both sides
// are defined as eager which leads to the infinite loop; if only
// one side is marked as eager, then all is ok...
@@ -89,4 +102,56 @@
s.getTransaction().commit();
s.close();
}
+
+ public void testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelfFailureExpected() {
+ // long winded method name to say that this is a test specifically for HHH-2277 ;)
+ // essentially we have a bidirectional association where one side of the
+ // association is actually part of a composite PK.
+ //
+ // The way these are mapped causes the problem because both sides
+ // are defined as eager which leads to the infinite loop; if only
+ // one side is marked as eager, then all is ok. In other words the
+ // problem arises when both pieces of instance data are coming from
+ // the same result set. This is because no "entry" can be placed
+ // into the persistence context for the association with the
+ // composite key because we are in the process of trying to build
+ // the composite-id instance
+ Session s = openSession();
+ s.beginTransaction();
+ Customer cust = new Customer( "Acme, Inc." );
+ Order order = new Order( new Order.Id( cust, 1 ) );
+ cust.getOrders().add( order );
+ s.save( cust );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ try {
+ cust = ( Customer ) s.get( Customer.class, cust.getId() );
+ }
+ catch( OverflowCondition overflow ) {
+ fail( "get()/load() caused overflow condition" );
+ }
+ s.delete( cust );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ private static class OverflowCondition extends RuntimeException {
+ }
+
+ private static class CustomLoadListener extends DefaultLoadEventListener {
+ private int internalLoadCount = 0;
+ public void onLoad(LoadEvent event, LoadType loadType) throws HibernateException {
+ if ( LoadEventListener.INTERNAL_LOAD_EAGER.getName().equals( loadType.getName() ) ) {
+ internalLoadCount++;
+ if ( internalLoadCount > 10 ) {
+ throw new OverflowCondition();
+ }
+ }
+ super.onLoad( event, loadType );
+ internalLoadCount--;
+ }
+ }
}
17 years, 1 month
Hibernate SVN: r11334 - branches/Branch_3_2/Hibernate3/test/org/hibernate/test/keymanytoone/bidir/component.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-03-22 13:36:43 -0400 (Thu, 22 Mar 2007)
New Revision: 11334
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java
Log:
HHH-2277 : key-many-to-one (bidir + eager) : test
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java 2007-03-22 17:35:22 UTC (rev 11333)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java 2007-03-22 17:36:43 UTC (rev 11334)
@@ -3,6 +3,10 @@
import junit.framework.Test;
import org.hibernate.Session;
+import org.hibernate.HibernateException;
+import org.hibernate.event.def.DefaultLoadEventListener;
+import org.hibernate.event.LoadEvent;
+import org.hibernate.event.LoadEventListener;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
@@ -12,6 +16,7 @@
* @author Steve Ebersole
*/
public class EagerKeyManyToOneTest extends TestCase {
+
public EagerKeyManyToOneTest(String name) {
super( name );
}
@@ -27,6 +32,12 @@
protected void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
+ LoadEventListener[] baseListeners = cfg.getEventListeners().getLoadEventListeners();
+ int baseLength = baseListeners.length;
+ LoadEventListener[] expandedListeners = new LoadEventListener[ baseLength + 1 ];
+ expandedListeners[ 0 ] = new CustomLoadListener();
+ System.arraycopy( baseListeners, 0, expandedListeners, 1, baseLength );
+ cfg.getEventListeners().setLoadEventListeners( expandedListeners );
}
public void testSaveCascadedToKeyManyToOne() {
@@ -62,6 +73,8 @@
// essentially we have a bidirectional association where one side of the
// association is actually part of a composite PK
//
+// See #testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelfFailureExpected() below...
+//
// The way these are mapped causes the problem because both sides
// are defined as eager which leads to the infinite loop; if only
// one side is marked as eager, then all is ok...
@@ -89,4 +102,56 @@
s.getTransaction().commit();
s.close();
}
+
+ public void testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelfFailureExpected() {
+ // long winded method name to say that this is a test specifically for HHH-2277 ;)
+ // essentially we have a bidirectional association where one side of the
+ // association is actually part of a composite PK.
+ //
+ // The way these are mapped causes the problem because both sides
+ // are defined as eager which leads to the infinite loop; if only
+ // one side is marked as eager, then all is ok. In other words the
+ // problem arises when both pieces of instance data are coming from
+ // the same result set. This is because no "entry" can be placed
+ // into the persistence context for the association with the
+ // composite key because we are in the process of trying to build
+ // the composite-id instance
+ Session s = openSession();
+ s.beginTransaction();
+ Customer cust = new Customer( "Acme, Inc." );
+ Order order = new Order( new Order.Id( cust, 1 ) );
+ cust.getOrders().add( order );
+ s.save( cust );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ try {
+ cust = ( Customer ) s.get( Customer.class, cust.getId() );
+ }
+ catch( OverflowCondition overflow ) {
+ fail( "get()/load() caused overflow condition" );
+ }
+ s.delete( cust );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ private static class OverflowCondition extends RuntimeException {
+ }
+
+ private static class CustomLoadListener extends DefaultLoadEventListener {
+ private int internalLoadCount = 0;
+ public void onLoad(LoadEvent event, LoadType loadType) throws HibernateException {
+ if ( LoadEventListener.INTERNAL_LOAD_EAGER.getName().equals( loadType.getName() ) ) {
+ internalLoadCount++;
+ if ( internalLoadCount > 10 ) {
+ throw new OverflowCondition();
+ }
+ }
+ super.onLoad( event, loadType );
+ internalLoadCount--;
+ }
+ }
}
17 years, 1 month
Hibernate SVN: r11333 - in branches/Branch_3_2/Hibernate3: test/org/hibernate/junit/functional and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-03-22 13:35:22 -0400 (Thu, 22 Mar 2007)
New Revision: 11333
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/AbstractBatcher.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/SuppliedConnectionTest.java
Log:
sybase testsuite
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/AbstractBatcher.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/AbstractBatcher.java 2007-03-22 17:34:55 UTC (rev 11332)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/jdbc/AbstractBatcher.java 2007-03-22 17:35:22 UTC (rev 11333)
@@ -196,17 +196,21 @@
return rs;
}
+
public void closeQueryStatement(PreparedStatement ps, ResultSet rs) throws SQLException {
- statementsToClose.remove( ps );
+ boolean psStillThere = statementsToClose.remove( ps );
try {
if ( rs != null ) {
- resultSetsToClose.remove( rs );
- logCloseResults();
- rs.close();
+ if ( resultSetsToClose.remove( rs ) ) {
+ logCloseResults();
+ rs.close();
+ }
}
}
finally {
- closeQueryStatement( ps );
+ if ( psStillThere ) {
+ closeQueryStatement( ps );
+ }
}
}
@@ -313,6 +317,10 @@
// no big deal
log.warn("Could not close a JDBC result set", e);
}
+ catch (Throwable e) {
+ // sybase driver (jConnect) throwing NPE here in certain cases
+ log.warn("Could not close a JDBC result set", e);
+ }
}
resultSetsToClose.clear();
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java 2007-03-22 17:34:55 UTC (rev 11332)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java 2007-03-22 17:35:22 UTC (rev 11333)
@@ -118,6 +118,7 @@
assertAllDataRemoved();
}
catch ( Throwable e ) {
+ log.trace( "test run resulted in error; attempting to cleanup", e );
try {
if ( session != null && session.isOpen() ) {
if ( session.isConnected() ) {
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/SuppliedConnectionTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/SuppliedConnectionTest.java 2007-03-22 17:34:55 UTC (rev 11332)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/connections/SuppliedConnectionTest.java 2007-03-22 17:35:22 UTC (rev 11333)
@@ -52,20 +52,31 @@
cfg.setProperty( Environment.RELEASE_CONNECTIONS, ConnectionReleaseMode.ON_CLOSE.toString() );
cfg.setProperty( Environment.CONNECTION_PROVIDER, UserSuppliedConnectionProvider.class.getName() );
boolean supportsScroll = true;
+ Connection conn = null;
try {
- Connection conn = cp.getConnection();
+ conn = cp.getConnection();
supportsScroll = conn.getMetaData().supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE);
}
catch( Throwable ignore ) {
}
+ finally {
+ if ( conn != null ) {
+ try {
+ conn.close();
+ }
+ catch( Throwable ignore ) {
+ // ignore it...
+ }
+ }
+ }
cfg.setProperty( Environment.USE_SCROLLABLE_RESULTSET, "" + supportsScroll );
}
- protected boolean dropAfterFailure() {
+ public boolean createSchema() {
return false;
}
- protected boolean recreateSchema() {
+ public boolean recreateSchemaAfterFailure() {
return false;
}
17 years, 1 month
Hibernate SVN: r11332 - in trunk/Hibernate3: test/org/hibernate/junit/functional and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-03-22 13:34:55 -0400 (Thu, 22 Mar 2007)
New Revision: 11332
Modified:
trunk/Hibernate3/src/org/hibernate/jdbc/AbstractBatcher.java
trunk/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java
trunk/Hibernate3/test/org/hibernate/test/connections/SuppliedConnectionTest.java
Log:
sybase testsuite
Modified: trunk/Hibernate3/src/org/hibernate/jdbc/AbstractBatcher.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/jdbc/AbstractBatcher.java 2007-03-22 14:56:41 UTC (rev 11331)
+++ trunk/Hibernate3/src/org/hibernate/jdbc/AbstractBatcher.java 2007-03-22 17:34:55 UTC (rev 11332)
@@ -196,17 +196,21 @@
return rs;
}
+
public void closeQueryStatement(PreparedStatement ps, ResultSet rs) throws SQLException {
- statementsToClose.remove( ps );
+ boolean psStillThere = statementsToClose.remove( ps );
try {
if ( rs != null ) {
- resultSetsToClose.remove( rs );
- logCloseResults();
- rs.close();
+ if ( resultSetsToClose.remove( rs ) ) {
+ logCloseResults();
+ rs.close();
+ }
}
}
finally {
- closeQueryStatement( ps );
+ if ( psStillThere ) {
+ closeQueryStatement( ps );
+ }
}
}
@@ -313,6 +317,10 @@
// no big deal
log.warn("Could not close a JDBC result set", e);
}
+ catch (Throwable e) {
+ // sybase driver (jConnect) throwing NPE here in certain cases
+ log.warn("Could not close a JDBC result set", e);
+ }
}
resultSetsToClose.clear();
Modified: trunk/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java 2007-03-22 14:56:41 UTC (rev 11331)
+++ trunk/Hibernate3/test/org/hibernate/junit/functional/FunctionalTestCase.java 2007-03-22 17:34:55 UTC (rev 11332)
@@ -118,6 +118,7 @@
assertAllDataRemoved();
}
catch ( Throwable e ) {
+ log.trace( "test run resulted in error; attempting to cleanup", e );
try {
if ( session != null && session.isOpen() ) {
if ( session.isConnected() ) {
Modified: trunk/Hibernate3/test/org/hibernate/test/connections/SuppliedConnectionTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/connections/SuppliedConnectionTest.java 2007-03-22 14:56:41 UTC (rev 11331)
+++ trunk/Hibernate3/test/org/hibernate/test/connections/SuppliedConnectionTest.java 2007-03-22 17:34:55 UTC (rev 11332)
@@ -52,20 +52,31 @@
cfg.setProperty( Environment.RELEASE_CONNECTIONS, ConnectionReleaseMode.ON_CLOSE.toString() );
cfg.setProperty( Environment.CONNECTION_PROVIDER, UserSuppliedConnectionProvider.class.getName() );
boolean supportsScroll = true;
+ Connection conn = null;
try {
- Connection conn = cp.getConnection();
+ conn = cp.getConnection();
supportsScroll = conn.getMetaData().supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE);
}
catch( Throwable ignore ) {
}
+ finally {
+ if ( conn != null ) {
+ try {
+ conn.close();
+ }
+ catch( Throwable ignore ) {
+ // ignore it...
+ }
+ }
+ }
cfg.setProperty( Environment.USE_SCROLLABLE_RESULTSET, "" + supportsScroll );
}
- protected boolean dropAfterFailure() {
+ public boolean createSchema() {
return false;
}
- protected boolean recreateSchema() {
+ public boolean recreateSchemaAfterFailure() {
return false;
}
17 years, 1 month
Hibernate SVN: r11331 - in branches/Branch_3_2/Hibernate3/test/org/hibernate/test: orphan and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-03-22 10:56:41 -0400 (Thu, 22 Mar 2007)
New Revision: 11331
Added:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/id/Product.hbm.xml
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/id/Product.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/id/UseIdentifierRollbackTest.java
Removed:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanIdRollbackTest.java
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/ProductAndIdRollback.hbm.xml
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanSuite.java
Log:
Remove unfinished test, add test for use_identifier_rollback
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/id/Product.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/id/Product.hbm.xml (rev 0)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/id/Product.hbm.xml 2007-03-22 14:56:41 UTC (rev 11331)
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+
+-->
+
+<hibernate-mapping package="org.hibernate.test.id">
+
+ <class name="Product" table="t_product">
+ <id name="name">
+ <generator class="uuid"/>
+ </id>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/id/Product.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/id/Product.java (rev 0)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/id/Product.java 2007-03-22 14:56:41 UTC (rev 11331)
@@ -0,0 +1,17 @@
+//$Id: $
+package org.hibernate.test.id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class Product {
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/id/UseIdentifierRollbackTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/id/UseIdentifierRollbackTest.java (rev 0)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/id/UseIdentifierRollbackTest.java 2007-03-22 14:56:41 UTC (rev 11331)
@@ -0,0 +1,44 @@
+//$Id: $
+package org.hibernate.test.id;
+
+import org.hibernate.test.TestCase;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import junit.framework.Test;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class UseIdentifierRollbackTest extends TestCase {
+ public UseIdentifierRollbackTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "id/Product.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty( Environment.USE_IDENTIFIER_ROLLBACK, "true");
+ super.configure( cfg );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( UseIdentifierRollbackTest.class );
+ }
+
+ public void testSimpleRollback() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product();
+ assertNull( prod.getName() );
+ session.persist(prod);
+ session.flush();
+ assertNotNull( prod.getName() );
+ t.rollback();
+ session.close();
+ }
+}
Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanIdRollbackTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanIdRollbackTest.java 2007-03-22 14:56:08 UTC (rev 11330)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanIdRollbackTest.java 2007-03-22 14:56:41 UTC (rev 11331)
@@ -1,52 +0,0 @@
-//$Id$
-package org.hibernate.test.orphan;
-
-import junit.framework.Test;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.junit.functional.FunctionalTestCase;
-import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-
-/**
- * @author Emmanuel Bernard
- */
-public class OrphanIdRollbackTest extends FunctionalTestCase {
-
- public OrphanIdRollbackTest(String str) {
- super(str);
- }
-
- public String[] getMappings() {
- return new String[] { "orphan/ProductAndIdRollback.hbm.xml" };
- }
-
- public void configure(Configuration cfg) {
- cfg.setProperty( Environment.USE_IDENTIFIER_ROLLBACK, "true");
- super.configure( cfg );
- }
-
- public static Test suite() {
- return new FunctionalTestClassTestSuite( OrphanIdRollbackTest.class );
- }
-
- public void testOrphanDeleteOnDelete() {
- Session session = openSession();
- Transaction t = session.beginTransaction();
- Product prod = new Product();
- session.persist(prod);
- session.flush();
- t.commit();
- session.close();
- session = openSession();
- t = session.beginTransaction();
- prod = (Product) session.get( Product.class, prod.getName() );
- session.delete(prod);
- t.commit();
- session.close();
- }
-
-}
-
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanSuite.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanSuite.java 2007-03-22 14:56:08 UTC (rev 11330)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/OrphanSuite.java 2007-03-22 14:56:41 UTC (rev 11331)
@@ -11,7 +11,6 @@
public class OrphanSuite {
public static Test suite() {
TestSuite suite = new TestSuite( "orphan delete suite" );
- suite.addTest( OrphanIdRollbackTest.suite() );
suite.addTest( OrphanTest.suite() );
suite.addTest( PropertyRefTest.suite() );
return suite;
Deleted: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/ProductAndIdRollback.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/ProductAndIdRollback.hbm.xml 2007-03-22 14:56:08 UTC (rev 11330)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/orphan/ProductAndIdRollback.hbm.xml 2007-03-22 14:56:41 UTC (rev 11331)
@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<!--
-
-
--->
-
-<hibernate-mapping package="org.hibernate.test.orphan">
-
- <class name="Product" table="t_product">
- <id name="name">
- <generator class="uuid"/>
- </id>
- <set name="parts" cascade="all,delete-orphan" fetch="join">
- <key column="productName" not-null="true"/>
- <one-to-many class="Part"/>
- </set>
- </class>
-
- <class name="Part" table="t_part">
- <id name="name"/>
- <property name="description" not-null="true"/>
- </class>
-
-</hibernate-mapping>
\ No newline at end of file
17 years, 1 month
Hibernate SVN: r11330 - in trunk/Hibernate3/test/org/hibernate/test: orphan and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-03-22 10:56:08 -0400 (Thu, 22 Mar 2007)
New Revision: 11330
Added:
trunk/Hibernate3/test/org/hibernate/test/id/Product.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/id/Product.java
trunk/Hibernate3/test/org/hibernate/test/id/UseIdentifierRollbackTest.java
Removed:
trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanIdRollbackTest.java
trunk/Hibernate3/test/org/hibernate/test/orphan/ProductAndIdRollback.hbm.xml
Modified:
trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanSuite.java
Log:
Remove unfinished test, add test for use_identifier_rollback
Added: trunk/Hibernate3/test/org/hibernate/test/id/Product.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/id/Product.hbm.xml (rev 0)
+++ trunk/Hibernate3/test/org/hibernate/test/id/Product.hbm.xml 2007-03-22 14:56:08 UTC (rev 11330)
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+
+-->
+
+<hibernate-mapping package="org.hibernate.test.id">
+
+ <class name="Product" table="t_product">
+ <id name="name">
+ <generator class="uuid"/>
+ </id>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/Hibernate3/test/org/hibernate/test/id/Product.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/id/Product.java (rev 0)
+++ trunk/Hibernate3/test/org/hibernate/test/id/Product.java 2007-03-22 14:56:08 UTC (rev 11330)
@@ -0,0 +1,17 @@
+//$Id: $
+package org.hibernate.test.id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class Product {
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/test/id/UseIdentifierRollbackTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/id/UseIdentifierRollbackTest.java (rev 0)
+++ trunk/Hibernate3/test/org/hibernate/test/id/UseIdentifierRollbackTest.java 2007-03-22 14:56:08 UTC (rev 11330)
@@ -0,0 +1,44 @@
+//$Id: $
+package org.hibernate.test.id;
+
+import org.hibernate.test.TestCase;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import junit.framework.Test;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class UseIdentifierRollbackTest extends TestCase {
+ public UseIdentifierRollbackTest(String str) {
+ super(str);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "id/Product.hbm.xml" };
+ }
+
+ public void configure(Configuration cfg) {
+ cfg.setProperty( Environment.USE_IDENTIFIER_ROLLBACK, "true");
+ super.configure( cfg );
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( UseIdentifierRollbackTest.class );
+ }
+
+ public void testSimpleRollback() {
+ Session session = openSession();
+ Transaction t = session.beginTransaction();
+ Product prod = new Product();
+ assertNull( prod.getName() );
+ session.persist(prod);
+ session.flush();
+ assertNotNull( prod.getName() );
+ t.rollback();
+ session.close();
+ }
+}
Deleted: trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanIdRollbackTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanIdRollbackTest.java 2007-03-22 06:31:51 UTC (rev 11329)
+++ trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanIdRollbackTest.java 2007-03-22 14:56:08 UTC (rev 11330)
@@ -1,52 +0,0 @@
-//$Id$
-package org.hibernate.test.orphan;
-
-import junit.framework.Test;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.junit.functional.FunctionalTestCase;
-import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
-
-/**
- * @author Emmanuel Bernard
- */
-public class OrphanIdRollbackTest extends FunctionalTestCase {
-
- public OrphanIdRollbackTest(String str) {
- super(str);
- }
-
- public String[] getMappings() {
- return new String[] { "orphan/ProductAndIdRollback.hbm.xml" };
- }
-
- public void configure(Configuration cfg) {
- cfg.setProperty( Environment.USE_IDENTIFIER_ROLLBACK, "true");
- super.configure( cfg );
- }
-
- public static Test suite() {
- return new FunctionalTestClassTestSuite( OrphanIdRollbackTest.class );
- }
-
- public void testOrphanDeleteOnDelete() {
- Session session = openSession();
- Transaction t = session.beginTransaction();
- Product prod = new Product();
- session.persist(prod);
- session.flush();
- t.commit();
- session.close();
- session = openSession();
- t = session.beginTransaction();
- prod = (Product) session.get( Product.class, prod.getName() );
- session.delete(prod);
- t.commit();
- session.close();
- }
-
-}
-
Modified: trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanSuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanSuite.java 2007-03-22 06:31:51 UTC (rev 11329)
+++ trunk/Hibernate3/test/org/hibernate/test/orphan/OrphanSuite.java 2007-03-22 14:56:08 UTC (rev 11330)
@@ -11,7 +11,6 @@
public class OrphanSuite {
public static Test suite() {
TestSuite suite = new TestSuite( "orphan delete suite" );
- suite.addTest( OrphanIdRollbackTest.suite() );
suite.addTest( OrphanTest.suite() );
suite.addTest( PropertyRefTest.suite() );
return suite;
Deleted: trunk/Hibernate3/test/org/hibernate/test/orphan/ProductAndIdRollback.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/orphan/ProductAndIdRollback.hbm.xml 2007-03-22 06:31:51 UTC (rev 11329)
+++ trunk/Hibernate3/test/org/hibernate/test/orphan/ProductAndIdRollback.hbm.xml 2007-03-22 14:56:08 UTC (rev 11330)
@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<!--
-
-
--->
-
-<hibernate-mapping package="org.hibernate.test.orphan">
-
- <class name="Product" table="t_product">
- <id name="name">
- <generator class="uuid"/>
- </id>
- <set name="parts" cascade="all,delete-orphan" fetch="join">
- <key column="productName" not-null="true"/>
- <one-to-many class="Part"/>
- </set>
- </class>
-
- <class name="Part" table="t_part">
- <id name="name"/>
- <property name="description" not-null="true"/>
- </class>
-
-</hibernate-mapping>
\ No newline at end of file
17 years, 1 month
Hibernate SVN: r11329 - trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/packaging.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-03-22 02:31:51 -0400 (Thu, 22 Mar 2007)
New Revision: 11329
Modified:
trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/packaging/PersistenceMetadata.java
trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java
Log:
EJB-281 Restore backward compatibility with JBoss AS 4.0.5
Modified: trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/packaging/PersistenceMetadata.java
===================================================================
--- trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/packaging/PersistenceMetadata.java 2007-03-21 12:51:14 UTC (rev 11328)
+++ trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/packaging/PersistenceMetadata.java 2007-03-22 06:31:51 UTC (rev 11329)
@@ -12,6 +12,8 @@
/**
* Simple represenation of persistence.xml
*
+ * Object used by JBoss EJB 3 for persistence.xml parsing
+ *
* @author <a href="mailto:bill@jboss.org">Bill Burke</a>
* @version $Revision$
*/
Modified: trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java
===================================================================
--- trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java 2007-03-21 12:51:14 UTC (rev 11328)
+++ trunk/HibernateExt/entitymanager/src/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java 2007-03-22 06:31:51 UTC (rev 11329)
@@ -74,7 +74,17 @@
return doc;
}
- public static List<PersistenceMetadata> deploy(URL url, Map overrides, EntityResolver resolver,
+ /**
+ * Method used by JBoss AS 4.0.5 for parsing
+ */
+ public static List<PersistenceMetadata> deploy(URL url, Map overrides, EntityResolver resolver) throws Exception {
+ return deploy(url, overrides, resolver, PersistenceUnitTransactionType.JTA);
+ }
+
+ /**
+ * Method used by JBoss EJB3 (4.2 and above) for parsing
+ */
+ public static List<PersistenceMetadata> deploy(URL url, Map overrides, EntityResolver resolver,
PersistenceUnitTransactionType defaultTransactionType) throws Exception {
Document doc = loadURL( url, resolver );
Element top = doc.getDocumentElement();
17 years, 1 month