Hibernate SVN: r14791 - core/branches/Branch_3_2_4_SP1_CP.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2008-06-20 13:42:09 -0400 (Fri, 20 Jun 2008)
New Revision: 14791
Modified:
core/branches/Branch_3_2_4_SP1_CP/
Log:
added proper svn:ignore
Property changes on: core/branches/Branch_3_2_4_SP1_CP
___________________________________________________________________
Name: svn:ignore
+ target
local
*.ipr
*.iws
*.iml
.classpath
.project
.nbattrs
*.log
*.properties
.clover
16 years, 6 months
Hibernate SVN: r14790 - in annotations/trunk/src/test/org/hibernate/test/annotations: immutable and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-19 12:34:50 -0400 (Thu, 19 Jun 2008)
New Revision: 14790
Added:
annotations/trunk/src/test/org/hibernate/test/annotations/immutable/
annotations/trunk/src/test/org/hibernate/test/annotations/immutable/Country.hbm.xml
annotations/trunk/src/test/org/hibernate/test/annotations/immutable/Country.java
annotations/trunk/src/test/org/hibernate/test/annotations/immutable/CountryHbm.java
annotations/trunk/src/test/org/hibernate/test/annotations/immutable/ImmutableTest.java
Log:
Some tests for @immutable - not quite sure so if one can test like this.
Added: annotations/trunk/src/test/org/hibernate/test/annotations/immutable/Country.hbm.xml
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/immutable/Country.hbm.xml (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/immutable/Country.hbm.xml 2008-06-19 16:34:50 UTC (rev 14790)
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Generated Nov 9, 2006 6:27:53 PM by Hibernate Tools 3.2.0.beta7 -->
+<hibernate-mapping>
+ <class name="org.hibernate.test.annotations.immutable.CountryHbm" mutable="false">
+ <id name="id" column="id" type="java.lang.Integer">
+ <generator class="native"/>
+ </id>
+ <property name="name"/>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/immutable/Country.hbm.xml
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: annotations/trunk/src/test/org/hibernate/test/annotations/immutable/Country.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/immutable/Country.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/immutable/Country.java 2008-06-19 16:34:50 UTC (rev 14790)
@@ -0,0 +1,39 @@
+//$Id$
+package org.hibernate.test.annotations.immutable;
+
+/**
+ * @author Hardy Ferentschik
+ */
+import java.io.Serializable;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.hibernate.annotations.Immutable;
+
+@Entity
+@Immutable
+@SuppressWarnings("serial")
+public class Country implements Serializable {
+ private Integer id;
+ private String name;
+
+ @Id
+ @GeneratedValue
+ public Integer getId() {
+ return id;
+ }
+
+ @Immutable
+ public String getName() {
+ return name;
+ }
+
+ public void setId(Integer integer) {
+ id = integer;
+ }
+
+ public void setName(String string) {
+ name = string;
+ }
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/immutable/Country.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: annotations/trunk/src/test/org/hibernate/test/annotations/immutable/CountryHbm.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/immutable/CountryHbm.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/immutable/CountryHbm.java 2008-06-19 16:34:50 UTC (rev 14790)
@@ -0,0 +1,29 @@
+//$Id$
+package org.hibernate.test.annotations.immutable;
+
+/**
+ * @author Hardy Ferentschik
+ */
+import java.io.Serializable;
+
+@SuppressWarnings("serial")
+public class CountryHbm implements Serializable {
+ private Integer id;
+ private String name;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setId(Integer integer) {
+ id = integer;
+ }
+
+ public void setName(String string) {
+ name = string;
+ }
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/immutable/CountryHbm.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: annotations/trunk/src/test/org/hibernate/test/annotations/immutable/ImmutableTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/immutable/ImmutableTest.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/immutable/ImmutableTest.java 2008-06-19 16:34:50 UTC (rev 14790)
@@ -0,0 +1,85 @@
+//$Id$
+package org.hibernate.test.annotations.immutable;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.test.annotations.TestCase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Tests for <code>Immutable</code> annotation.
+ *
+ * @author Hardy Ferentschik
+ */
+@SuppressWarnings("unchecked")
+public class ImmutableTest extends TestCase {
+
+ private Logger log = LoggerFactory.getLogger(ImmutableTest.class);
+
+ public ImmutableTest(String x) {
+ super(x);
+ }
+
+ public void testImmutableEntity() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Country country = new Country();
+ country.setName("Germany");
+ s.persist(country);
+ tx.commit();
+ s.close();
+
+ try {
+ s = openSession();
+ tx = s.beginTransaction();
+ Country germany = (Country) s.get(Country.class, country.getId());
+ assertNotNull(germany);
+ germany.setName("France");
+ s.save(germany);
+ s.delete(germany);
+ tx.commit();
+ s.close();
+// fail();
+ } catch (Exception e) {
+ log.debug("success");
+ }
+ }
+
+ public void testImmutableEntityWithMappingFile() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ CountryHbm country = new CountryHbm();
+ country.setName("Germany");
+ s.persist(country);
+ tx.commit();
+ s.close();
+
+ try {
+ s = openSession();
+ tx = s.beginTransaction();
+ CountryHbm germany = (CountryHbm) s.get(CountryHbm.class, country.getId());
+ assertNotNull(germany);
+ germany.setName("France");
+ s.save(germany);
+ s.delete(germany);
+ tx.commit();
+ s.close();
+// fail();
+ } catch (Exception e) {
+ log.debug("success");
+ }
+ }
+
+ /**
+ * @see org.hibernate.test.annotations.TestCase#getMappings()
+ */
+ protected Class[] getMappings() {
+ return new Class[] { Country.class };
+ }
+
+ @Override
+ protected String[] getXmlFiles() {
+ return new String[]{"org/hibernate/test/annotations/immutable/Country.hbm.xml"};
+ }
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/immutable/ImmutableTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
16 years, 6 months
Hibernate SVN: r14789 - annotations/trunk/src/test/org/hibernate/test/annotations/onetomany.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-19 12:32:39 -0400 (Thu, 19 Jun 2008)
New Revision: 14789
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/onetomany/OneToManyTest.java
Log:
Code and import cleanup.
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/onetomany/OneToManyTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/onetomany/OneToManyTest.java 2008-06-19 16:23:58 UTC (rev 14788)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/onetomany/OneToManyTest.java 2008-06-19 16:32:39 UTC (rev 14789)
@@ -7,7 +7,6 @@
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
-import java.util.Set;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
@@ -25,6 +24,7 @@
*
* @author Emmanuel Bernard
*/
+@SuppressWarnings("unchecked")
public class OneToManyTest extends TestCase {
public OneToManyTest(String x) {
@@ -395,7 +395,7 @@
s.persist( org );
s.flush();
s.clear();
- List l = s.createQuery( "select org from Organisation org left join fetch org.organisationUsers" ).list();
+ s.createQuery( "select org from Organisation org left join fetch org.organisationUsers" ).list();
s.getTransaction().rollback();
s.close();
}
16 years, 6 months
Hibernate SVN: r14788 - core/trunk/core/src/main/java/org/hibernate/jdbc.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2008-06-19 12:23:58 -0400 (Thu, 19 Jun 2008)
New Revision: 14788
Modified:
core/trunk/core/src/main/java/org/hibernate/jdbc/AbstractBatcher.java
Log:
HHH-3006 : occansional infinite loop on JTA tx-timeout
Modified: core/trunk/core/src/main/java/org/hibernate/jdbc/AbstractBatcher.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/jdbc/AbstractBatcher.java 2008-06-19 16:21:18 UTC (rev 14787)
+++ core/trunk/core/src/main/java/org/hibernate/jdbc/AbstractBatcher.java 2008-06-19 16:23:58 UTC (rev 14788)
@@ -8,6 +8,7 @@
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.ConcurrentModificationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -296,40 +297,62 @@
releasing = true;
try {
- if (batchUpdate!=null) batchUpdate.close();
+ if ( batchUpdate != null ) {
+ batchUpdate.close();
+ }
}
- catch (SQLException sqle) {
+ catch ( SQLException sqle ) {
//no big deal
- log.warn("Could not close a JDBC prepared statement", sqle);
+ log.warn( "Could not close a JDBC prepared statement", sqle );
}
- batchUpdate=null;
- batchUpdateSQL=null;
+ batchUpdate = null;
+ batchUpdateSQL = null;
Iterator iter = resultSetsToClose.iterator();
while ( iter.hasNext() ) {
try {
logCloseResults();
- ( (ResultSet) iter.next() ).close();
+ ( ( ResultSet ) iter.next() ).close();
}
- catch (SQLException e) {
+ catch ( SQLException e ) {
// no big deal
- log.warn("Could not close a JDBC result set", e);
+ 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);
+ catch ( ConcurrentModificationException e ) {
+ // this has been shown to happen occasionally in rare cases
+ // when using a transaction manager + transaction-timeout
+ // where the timeout calls back through Hibernate's
+ // registered transaction synchronization on a separate
+ // "reaping" thread. In cases where that reaping thread
+ // executes through this block at the same time the main
+ // application thread does we can get into situations where
+ // these CMEs occur. And though it is not "allowed" per-se,
+ // the end result without handling it specifically is infinite
+ // looping. So here, we simply break the loop
+ log.info( "encountered CME attempting to release batcher; assuming cause is tx-timeout scenario and ignoring" );
+ break;
}
+ catch ( Throwable e ) {
+ // sybase driver (jConnect) throwing NPE here in certain
+ // cases, but we'll just handle the general "unexpected" case
+ log.warn( "Could not close a JDBC result set", e );
+ }
}
resultSetsToClose.clear();
iter = statementsToClose.iterator();
while ( iter.hasNext() ) {
try {
- closeQueryStatement( (PreparedStatement) iter.next() );
+ closeQueryStatement( ( PreparedStatement ) iter.next() );
}
- catch (SQLException e) {
+ catch ( ConcurrentModificationException e ) {
+ // see explanation above...
+ log.info( "encountered CME attempting to release batcher; assuming cause is tx-timeout scenario and ignoring" );
+ break;
+ }
+ catch ( SQLException e ) {
// no big deal
- log.warn("Could not close a JDBC statement", e);
+ log.warn( "Could not close a JDBC statement", e );
}
}
statementsToClose.clear();
16 years, 6 months
Hibernate SVN: r14787 - core/branches/Branch_3_2/src/org/hibernate/jdbc.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2008-06-19 12:21:18 -0400 (Thu, 19 Jun 2008)
New Revision: 14787
Modified:
core/branches/Branch_3_2/src/org/hibernate/jdbc/AbstractBatcher.java
Log:
HHH-3006 : occansional infinite loop on JTA tx-timeout
Modified: core/branches/Branch_3_2/src/org/hibernate/jdbc/AbstractBatcher.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/jdbc/AbstractBatcher.java 2008-06-19 14:59:11 UTC (rev 14786)
+++ core/branches/Branch_3_2/src/org/hibernate/jdbc/AbstractBatcher.java 2008-06-19 16:21:18 UTC (rev 14787)
@@ -8,6 +8,7 @@
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.ConcurrentModificationException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -298,40 +299,62 @@
releasing = true;
try {
- if (batchUpdate!=null) batchUpdate.close();
+ if ( batchUpdate != null ) {
+ batchUpdate.close();
+ }
}
- catch (SQLException sqle) {
+ catch ( SQLException sqle ) {
//no big deal
- log.warn("Could not close a JDBC prepared statement", sqle);
+ log.warn( "Could not close a JDBC prepared statement", sqle );
}
- batchUpdate=null;
- batchUpdateSQL=null;
+ batchUpdate = null;
+ batchUpdateSQL = null;
Iterator iter = resultSetsToClose.iterator();
while ( iter.hasNext() ) {
try {
logCloseResults();
- ( (ResultSet) iter.next() ).close();
+ ( ( ResultSet ) iter.next() ).close();
}
- catch (SQLException e) {
+ catch ( SQLException e ) {
// no big deal
- log.warn("Could not close a JDBC result set", e);
+ 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);
+ catch ( ConcurrentModificationException e ) {
+ // this has been shown to happen occasionally in rare cases
+ // when using a transaction manager + transaction-timeout
+ // where the timeout calls back through Hibernate's
+ // registered transaction synchronization on a separate
+ // "reaping" thread. In cases where that reaping thread
+ // executes through this block at the same time the main
+ // application thread does we can get into situations where
+ // these CMEs occur. And though it is not "allowed" per-se,
+ // the end result without handling it specifically is infinite
+ // looping. So here, we simply break the loop
+ log.info( "encountered CME attempting to release batcher; assuming cause is tx-timeout scenario and ignoring" );
+ break;
}
+ catch ( Throwable e ) {
+ // sybase driver (jConnect) throwing NPE here in certain
+ // cases, but we'll just handle the general "unexpected" case
+ log.warn( "Could not close a JDBC result set", e );
+ }
}
resultSetsToClose.clear();
iter = statementsToClose.iterator();
while ( iter.hasNext() ) {
try {
- closeQueryStatement( (PreparedStatement) iter.next() );
+ closeQueryStatement( ( PreparedStatement ) iter.next() );
}
- catch (SQLException e) {
+ catch ( ConcurrentModificationException e ) {
+ // see explanation above...
+ log.info( "encountered CME attempting to release batcher; assuming cause is tx-timeout scenario and ignoring" );
+ break;
+ }
+ catch ( SQLException e ) {
// no big deal
- log.warn("Could not close a JDBC statement", e);
+ log.warn( "Could not close a JDBC statement", e );
}
}
statementsToClose.clear();
16 years, 6 months
Hibernate SVN: r14786 - in annotations/trunk/src: test/org/hibernate/test/annotations/naturalid and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-19 10:59:11 -0400 (Thu, 19 Jun 2008)
New Revision: 14786
Modified:
annotations/trunk/src/java/org/hibernate/cfg/AnnotationBinder.java
annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnSingleManyToOneTest.java
annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdTest.java
Log:
ANN-750
- Updated tests
- Made sure that binder.setProperty(inferredData.getProperty()); is called in AnnotationBinder.bindManyToOne. This will ensure that @NaturalId gets properly processed.
Modified: annotations/trunk/src/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/AnnotationBinder.java 2008-06-19 10:44:33 UTC (rev 14785)
+++ annotations/trunk/src/java/org/hibernate/cfg/AnnotationBinder.java 2008-06-19 14:59:11 UTC (rev 14786)
@@ -1993,6 +1993,7 @@
}
binder.setPropertyAccessorName( inferredData.getDefaultAccess() );
binder.setCascade( cascadeStrategy );
+ binder.setProperty(inferredData.getProperty());
Property prop = binder.make();
//composite FK columns are in the same table so its OK
propertyHolder.addProperty( prop, columns );
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnSingleManyToOneTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnSingleManyToOneTest.java 2008-06-19 10:44:33 UTC (rev 14785)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdOnSingleManyToOneTest.java 2008-06-19 14:59:11 UTC (rev 14786)
@@ -26,13 +26,13 @@
public void testMappingProperties() {
log.warn("Commented out test");
-//TODO Fix test
-// ClassMetadata metaData = getSessions().getClassMetadata(
-// NaturalIdOnManyToOne.class);
-// assertTrue("Class should have a natural key", metaData
-// .hasNaturalIdentifier());
-// int[] propertiesIndex = metaData.getNaturalIdentifierProperties();
-// assertTrue("Wrong number of elements", propertiesIndex.length == 1);
+
+ ClassMetadata metaData = getSessions().getClassMetadata(
+ NaturalIdOnManyToOne.class);
+ assertTrue("Class should have a natural key", metaData
+ .hasNaturalIdentifier());
+ int[] propertiesIndex = metaData.getNaturalIdentifierProperties();
+ assertTrue("Wrong number of elements", propertiesIndex.length == 1);
}
public void testManyToOneNaturalIdCached() {
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdTest.java 2008-06-19 10:44:33 UTC (rev 14785)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/naturalid/NaturalIdTest.java 2008-06-19 14:59:11 UTC (rev 14786)
@@ -26,7 +26,7 @@
assertTrue("Class should have a natural key", metaData
.hasNaturalIdentifier());
int[] propertiesIndex = metaData.getNaturalIdentifierProperties();
- assertTrue("Wrong number of elements", propertiesIndex.length == 1);
+ assertTrue("Wrong number of elements", propertiesIndex.length == 2);
}
public void testNaturalIdCached() {
16 years, 6 months
Hibernate SVN: r14785 - in annotations/trunk/src: test/org/hibernate/test/annotations/id and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-19 06:44:33 -0400 (Thu, 19 Jun 2008)
New Revision: 14785
Added:
annotations/trunk/src/test/org/hibernate/test/annotations/id/EnumIdTest.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Planet.java
annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/PlanetCheatSheet.java
Modified:
annotations/trunk/src/java/org/hibernate/cfg/AnnotationBinder.java
Log:
ANN-733
- Added test case
- Made sure that bindId() in AnnotationBinder calls SimpleValueBinder.setType() in order to set the column type to string resp. int. Before that was not done and hence the column type was some form of blob
Modified: annotations/trunk/src/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/AnnotationBinder.java 2008-06-19 10:42:20 UTC (rev 14784)
+++ annotations/trunk/src/java/org/hibernate/cfg/AnnotationBinder.java 2008-06-19 10:44:33 UTC (rev 14785)
@@ -715,7 +715,6 @@
isComponent,
propertyAnnotated,
propertyAccessor, entityBinder,
- null,
true,
false, mappings
);
@@ -1276,7 +1275,7 @@
generatedValue.generator() :
BinderHelper.ANNOTATION_STRING_DEFAULT;
if ( isComponent ) generatorType = "assigned"; //a component must not have any generator
- Type typeAnn = property.getAnnotation( Type.class );
+
bindId(
generatorType,
generator,
@@ -1287,10 +1286,10 @@
isComponent,
propertyAnnotated,
propertyAccessor, entityBinder,
- typeAnn,
false,
isIdentifierMapper, mappings
);
+
log.debug(
"Bind {} on {}", ( isComponent ? "@EmbeddedId" : "@Id" ), inferredData.getPropertyName()
);
@@ -1850,7 +1849,7 @@
Map<String, IdGenerator> localGenerators,
boolean isComposite,
boolean isPropertyAnnotated,
- String propertyAccessor, EntityBinder entityBinder, Type typeAnn, boolean isEmbedded,
+ String propertyAccessor, EntityBinder entityBinder, boolean isEmbedded,
boolean isIdentifierMapper, ExtendedMappings mappings
) {
/*
@@ -1895,7 +1894,7 @@
value.setColumns( columns );
value.setPersistentClassName( persistentClassName );
value.setMappings( mappings );
- value.setExplicitType( typeAnn );
+ value.setType( inferredData.getProperty(), inferredData.getClassOrElement() );
id = value.make();
}
rootClass.setIdentifier( id );
Added: annotations/trunk/src/test/org/hibernate/test/annotations/id/EnumIdTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/EnumIdTest.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/EnumIdTest.java 2008-06-19 10:44:33 UTC (rev 14785)
@@ -0,0 +1,62 @@
+//$Id$
+package org.hibernate.test.annotations.id;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.test.annotations.TestCase;
+import org.hibernate.test.annotations.id.entities.Planet;
+import org.hibernate.test.annotations.id.entities.PlanetCheatSheet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Tests for enum type as id.
+ *
+ * @author Hardy Ferentschik
+ * @see ANN-744
+ */
+@SuppressWarnings("unchecked")
+public class EnumIdTest extends TestCase {
+
+ private Logger log = LoggerFactory.getLogger(EnumIdTest.class);
+
+ public EnumIdTest(String x) {
+ super(x);
+ }
+
+ public void testEnumAsId() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ PlanetCheatSheet mercury = new PlanetCheatSheet();
+ mercury.setPlanet(Planet.MERCURY);
+ mercury.setMass(3.303e+23);
+ mercury.setRadius(2.4397e6);
+ mercury.setNumberOfInhabitants(0);
+ s.persist(mercury);
+ tx.commit();
+ s.close();
+
+ s = openSession();
+ tx = s.beginTransaction();
+ PlanetCheatSheet mercuryFromDb = (PlanetCheatSheet) s.get(PlanetCheatSheet.class, mercury.getPlanet());
+ assertNotNull(mercuryFromDb);
+ log.debug(mercuryFromDb.toString());
+ s.delete(mercuryFromDb);
+ tx.commit();
+ s.close();
+
+ s = openSession();
+ tx = s.beginTransaction();
+ mercury = (PlanetCheatSheet) s.get(PlanetCheatSheet.class, Planet.MERCURY);
+ assertNull(mercury);
+ tx.commit();
+ s.close();
+ }
+
+ /**
+ * @see org.hibernate.test.annotations.TestCase#getMappings()
+ */
+ protected Class[] getMappings() {
+ return new Class[] { PlanetCheatSheet.class };
+ }
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/id/EnumIdTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Planet.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Planet.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Planet.java 2008-06-19 10:44:33 UTC (rev 14785)
@@ -0,0 +1,6 @@
+// $Id:$
+package org.hibernate.test.annotations.id.entities;
+
+public enum Planet {
+ MERCURY, VENUS, EARTH, MARS, JUPITER, SATURN, URANUS, NEPTUNE, PLUTO;
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/Planet.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/PlanetCheatSheet.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/PlanetCheatSheet.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/PlanetCheatSheet.java 2008-06-19 10:44:33 UTC (rev 14785)
@@ -0,0 +1,85 @@
+package org.hibernate.test.annotations.id.entities;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Id;
+
+
+/**
+ * Test entity for enum type as id.
+ *
+ * @author Hardy Ferentschik
+ * @see ANN-744
+ */
+@Entity
+public class PlanetCheatSheet {
+
+ @Id
+ @Enumerated(EnumType.STRING)
+ @Column(name = "planet")
+ private Planet planet;
+
+ private double mass;
+
+ private double radius;
+
+ private long numberOfInhabitants;
+
+ public Planet getPlanet() {
+ return planet;
+ }
+
+ public void setPlanet(Planet planet) {
+ this.planet = planet;
+ }
+
+ public double getMass() {
+ return mass;
+ }
+
+ public void setMass(double mass) {
+ this.mass = mass;
+ }
+
+ public double getRadius() {
+ return radius;
+ }
+
+ public void setRadius(double radius) {
+ this.radius = radius;
+ }
+
+ public long getNumberOfInhabitants() {
+ return numberOfInhabitants;
+ }
+
+ public void setNumberOfInhabitants(long numberOfInhabitants) {
+ this.numberOfInhabitants = numberOfInhabitants;
+ }
+
+ /**
+ * Constructs a <code>String</code> with all attributes
+ * in name = value format.
+ *
+ * @return a <code>String</code> representation
+ * of this object.
+ */
+ public String toString()
+ {
+ final String TAB = " ";
+
+ String retValue = "";
+
+ retValue = "PlanetCheatSheet ( "
+ + super.toString() + TAB
+ + "planet = " + this.planet + TAB
+ + "mass = " + this.mass + TAB
+ + "radius = " + this.radius + TAB
+ + "numberOfInhabitants = " + this.numberOfInhabitants + TAB
+ + " )";
+
+ return retValue;
+ }
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/id/entities/PlanetCheatSheet.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
16 years, 6 months
Hibernate SVN: r14784 - annotations/trunk/src/test/org/hibernate/test/annotations/id.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-19 06:42:20 -0400 (Thu, 19 Jun 2008)
New Revision: 14784
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/id/IdClassTest.java
Log:
- Added @SupressWarnings
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/id/IdClassTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/id/IdClassTest.java 2008-06-19 09:54:03 UTC (rev 14783)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/id/IdClassTest.java 2008-06-19 10:42:20 UTC (rev 14784)
@@ -10,8 +10,9 @@
/**
* @author Emmanuel Bernard
*/
+@SuppressWarnings("unchecked")
public class IdClassTest extends TestCase {
-
+
public void testIdClassInSuperclass() throws Exception {
Tower tower = new Tower();
tower.latitude = 10.3;
16 years, 6 months
Hibernate SVN: r14783 - core/branches/Branch_3_2/src/org/hibernate/tool/hbm2ddl.
by hibernate-commits@lists.jboss.org
Author: anthonyHib
Date: 2008-06-19 05:54:03 -0400 (Thu, 19 Jun 2008)
New Revision: 14783
Modified:
core/branches/Branch_3_2/src/org/hibernate/tool/hbm2ddl/SchemaUpdate.java
core/branches/Branch_3_2/src/org/hibernate/tool/hbm2ddl/SchemaUpdateTask.java
Log:
HBX-757 fix
Modified: core/branches/Branch_3_2/src/org/hibernate/tool/hbm2ddl/SchemaUpdate.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/tool/hbm2ddl/SchemaUpdate.java 2008-06-19 08:32:30 UTC (rev 14782)
+++ core/branches/Branch_3_2/src/org/hibernate/tool/hbm2ddl/SchemaUpdate.java 2008-06-19 09:54:03 UTC (rev 14783)
@@ -2,6 +2,8 @@
package org.hibernate.tool.hbm2ddl;
import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.Writer;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
@@ -12,10 +14,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
+import org.hibernate.JDBCException;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.cfg.Settings;
import org.hibernate.dialect.Dialect;
+import org.hibernate.pretty.DDLFormatter;
import org.hibernate.util.ReflectHelper;
/**
@@ -31,6 +35,10 @@
private Configuration configuration;
private Dialect dialect;
private List exceptions;
+ private boolean haltOnError = false;
+ private boolean format = true;
+ private String outputFile = null;
+ private String delimiter;
public SchemaUpdate(Configuration cfg) throws HibernateException {
this( cfg, cfg.getProperties() );
@@ -116,6 +124,7 @@
Connection connection = null;
Statement stmt = null;
+ Writer outputFileWriter = null;
exceptions.clear();
@@ -137,20 +146,36 @@
log.info( "updating schema" );
+
+ if ( outputFile != null ) {
+ log.info( "writing generated schema to file: " + outputFile );
+ outputFileWriter = new FileWriter( outputFile );
+ }
+
String[] createSQL = configuration.generateSchemaUpdateScript( dialect, meta );
for ( int j = 0; j < createSQL.length; j++ ) {
final String sql = createSQL[j];
+ String formatted = format( sql );
try {
+ if ( delimiter != null ) {
+ formatted += delimiter;
+ }
if ( script ) {
- System.out.println( sql );
+ System.out.println( formatted );
}
+ if ( outputFile != null ) {
+ outputFileWriter.write( formatted + "\n" );
+ }
if ( doUpdate ) {
log.debug( sql );
- stmt.executeUpdate( sql );
+ stmt.executeUpdate( formatted );
}
}
catch ( SQLException e ) {
+ if ( haltOnError ) {
+ throw new JDBCException( "Error during DDL export", e );
+ }
exceptions.add( e );
log.error( "Unsuccessful: " + sql );
log.error( e.getMessage() );
@@ -176,7 +201,15 @@
exceptions.add( e );
log.error( "Error closing connection", e );
}
-
+ try {
+ if( outputFileWriter != null ) {
+ outputFileWriter.close();
+ }
+ }
+ catch(Exception e) {
+ exceptions.add(e);
+ log.error( "Error closing connection", e );
+ }
}
}
@@ -188,4 +221,26 @@
public List getExceptions() {
return exceptions;
}
+
+ public void setHaltOnError(boolean haltOnError) {
+ this.haltOnError = haltOnError;
+ }
+
+ public void setFormat(boolean format) {
+ this.format = format;
+ }
+
+ public void setOutputFile(String outputFile) {
+ this.outputFile = outputFile;
+ }
+
+ public void setDelimiter(String delimiter) {
+ this.delimiter = delimiter;
+ }
+
+ private String format(String sql) {
+ return format ?
+ new DDLFormatter( sql ).format() :
+ sql;
+ }
}
Modified: core/branches/Branch_3_2/src/org/hibernate/tool/hbm2ddl/SchemaUpdateTask.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/tool/hbm2ddl/SchemaUpdateTask.java 2008-06-19 08:32:30 UTC (rev 14782)
+++ core/branches/Branch_3_2/src/org/hibernate/tool/hbm2ddl/SchemaUpdateTask.java 2008-06-19 09:54:03 UTC (rev 14783)
@@ -47,9 +47,13 @@
private List fileSets = new LinkedList();
private File propertiesFile = null;
private File configurationFile = null;
+ private File outputFile = null;
private boolean quiet = false;
private boolean text = true;
+ private boolean haltOnError = false;
+ private String delimiter = null;
private String namingStrategy = null;
+
public void addFileset(FileSet set) {
fileSets.add(set);
@@ -174,11 +178,39 @@
properties.load( new FileInputStream(propertiesFile) );
}
cfg.setProperties(properties);
- return new SchemaUpdate(cfg);
+ SchemaUpdate su = new SchemaUpdate(cfg);
+ su.setOutputFile( outputFile.getPath() );
+ su.setDelimiter(delimiter);
+ su.setHaltOnError(haltOnError);
+ return su;
}
public void setNamingStrategy(String namingStrategy) {
this.namingStrategy = namingStrategy;
}
+ public File getOutputFile() {
+ return outputFile;
+ }
+
+ public void setOutputFile(File outputFile) {
+ this.outputFile = outputFile;
+ }
+
+ public boolean isHaltOnError() {
+ return haltOnError;
+ }
+
+ public void setHaltOnError(boolean haltOnError) {
+ this.haltOnError = haltOnError;
+ }
+
+ public String getDelimiter() {
+ return delimiter;
+ }
+
+ public void setDelimiter(String delimiter) {
+ this.delimiter = delimiter;
+ }
+
}
16 years, 6 months
Hibernate SVN: r14782 - in branches/Branch_3_2/HibernateExt/tools: src/java/org/hibernate/tool/hbm2x and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: anthonyHib
Date: 2008-06-19 04:32:30 -0400 (Thu, 19 Jun 2008)
New Revision: 14782
Modified:
branches/Branch_3_2/HibernateExt/tools/lib/testlibs/README.TXT
branches/Branch_3_2/HibernateExt/tools/lib/testlibs/hibernate3.jar
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Hbm2DDLExporter.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntHibernateToolTest.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/TestHelper.java
branches/Branch_3_2/HibernateExt/tools/src/testsupport/anttest-build.xml
Log:
HBX-757 fix
Modified: branches/Branch_3_2/HibernateExt/tools/lib/testlibs/README.TXT
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/lib/testlibs/README.TXT 2008-06-18 18:04:17 UTC (rev 14781)
+++ branches/Branch_3_2/HibernateExt/tools/lib/testlibs/README.TXT 2008-06-19 08:32:30 UTC (rev 14782)
@@ -3,4 +3,8 @@
Some of these libraries are only here for the purpose of verifying that the
generated code can compile.
-Jar files from JBoss 4.0.4.GA and jboss-seam-1.0.0.CR3
\ No newline at end of file
+Jar files from JBoss 4.0.4.GA and jboss-seam-1.0.0.CR3
+
+Warning: in order to run AntHibernateToolTest.testHbm2DDLExportExecution,testHbm2DDLLogic and testHbm2DDLUpdateExecution
+you must have an up to date hibernate core jar in your classpath.
+In lib\testlibs, provided hibernate3.jar allows you to run these tests
\ No newline at end of file
Modified: branches/Branch_3_2/HibernateExt/tools/lib/testlibs/hibernate3.jar
===================================================================
(Binary files differ)
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Hbm2DDLExporter.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Hbm2DDLExporter.java 2008-06-18 18:04:17 UTC (rev 14781)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Hbm2DDLExporter.java 2008-06-19 08:32:30 UTC (rev 14782)
@@ -11,11 +11,16 @@
package org.hibernate.tool.hbm2x;
import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.Iterator;
+import org.hibernate.HibernateException;
+import org.hibernate.JDBCException;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
+import org.hibernate.util.ReflectHelper;
/**
* Schema Export (.ddl) code generation.
@@ -73,7 +78,77 @@
final Configuration configuration = getConfiguration();
if (schemaUpdate) {
SchemaUpdate update = new SchemaUpdate(configuration);
- update.execute(scriptToConsole, exportToDatabase);
+
+ // classic schemaupdate execution, will work with all releases
+ if(outputFileName == null && delimiter == null && haltOnError && format)
+ update.execute(scriptToConsole, exportToDatabase);
+
+ // at least one of the parameter unmanaged by
+ // hibernate core prior versions is set
+ else {
+
+ /* working with reflection as no idea what hibernate core version is used */
+ try {
+ Class schemaUpdateClass = SchemaUpdate.class;
+
+ if (null != outputFileName) {
+ Method setOutputFile = schemaUpdateClass.getMethod("setOutputFile",
+ new Class[] {String.class});
+ setOutputFile.invoke(update, new Object[] {new File(getOutputDirectory(),
+ outputFileName).toString()});
+
+ log.debug("delimiter ='"+ delimiter + "'");
+ Method setDelimiter = schemaUpdateClass.getMethod("setDelimiter",
+ new Class[] {String.class});
+ setDelimiter.invoke(update, new Object[] {delimiter});
+
+ Method setFormat = schemaUpdateClass.getMethod("setFormat",
+ new Class[] {boolean.class});
+ setFormat.invoke(update, new Object[] {Boolean.valueOf(format)});
+
+ }
+
+ if (haltOnError) {
+ Method setHaltOnError = schemaUpdateClass.getMethod("setHaltOnError",
+ new Class[] {boolean.class});
+ setHaltOnError.invoke(update, new Object[] {Boolean.valueOf(haltOnError)});
+ }
+
+ update.execute(scriptToConsole, exportToDatabase);
+ if (!update.getExceptions().isEmpty()) {
+ int i = 1;
+ for (Iterator iterator = update.getExceptions().iterator(); iterator
+ .hasNext(); i++) {
+ Throwable element = (Throwable) iterator.next();
+ log.warn("Error #" + i + ": ", element);
+
+ }
+ log.error(i - 1 + " errors occurred while performing Hbm2DDLExporter.");
+ if (haltOnError) {
+ throw new ExporterException(
+ "Errors while performing Hbm2DDLExporter");
+ }
+ }
+
+ } catch (NoSuchMethodException e) {
+ log.error( "Error during DDL export, this version of hibernate doesn't support following " +
+ "SchemaUpdate parameters: haltonerror = true, format= true, delimiter and outputfilename" +
+ " either update hibernate3.jar or don't used the involved parameters", e );
+ } catch (IllegalArgumentException e) {
+ log.error( "Error during DDL export, this version of hibernate doesn't support following " +
+ "SchemaUpdate parameters: haltonerror = true, format= true, delimiter and outputfilename" +
+ " either update hibernate3.jar or don't used the involved parameters", e );
+ } catch (InvocationTargetException e) {
+ log.error( "Error during DDL export, this version of hibernate doesn't support following " +
+ "SchemaUpdate parameters: haltonerror = true, format= true, delimiter and outputfilename" +
+ " either update hibernate3.jar or don't used the involved parameters", e );
+ } catch (IllegalAccessException e) {
+ log.error( "Error during DDL export, this version of hibernate doesn't support following " +
+ "SchemaUpdate parameters: haltonerror = true, format= true, delimiter and outputfilename" +
+ " either update hibernate3.jar or don't used the involved parameters", e );
+ }
+ }
+
} else {
SchemaExport export = new SchemaExport(configuration);
if (null != outputFileName) {
@@ -90,22 +165,8 @@
} else {
export.execute(scriptToConsole, exportToDatabase, drop, create);
}
-
- if (!export.getExceptions().isEmpty()) {
- int i = 1;
- for (Iterator iterator = export.getExceptions().iterator(); iterator
- .hasNext(); i++) {
- Throwable element = (Throwable) iterator.next();
- log.warn("Error #" + i + ": ", element);
-
- }
- log.error(i - 1 + " errors occurred while performing Hbm2DDLExporter.");
- if (haltOnError) {
- throw new ExporterException(
- "Errors while performing Hbm2DDLExporter");
- }
- }
}
+
}
public void setExport(boolean export) {
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntHibernateToolTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntHibernateToolTest.java 2008-06-18 18:04:17 UTC (rev 14781)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/ant/AntHibernateToolTest.java 2008-06-19 08:32:30 UTC (rev 14782)
@@ -10,6 +10,9 @@
import junit.framework.TestSuite;
import org.apache.tools.ant.BuildException;
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.Session;
import org.hibernate.tool.test.TestHelper;
/**
@@ -34,36 +37,100 @@
}
public void testHbm2DDLLogic() {
+ cleanupOutputDir();
File baseDir = new File(project.getProperty("build.dir"), "topdown");
File onlyCreate = new File(baseDir, "onlycreate.sql");
File onlyDrop = new File(baseDir, "onlydrop.sql");
File dropAndCreate = new File(baseDir, "dropandcreate.sql");
+ File update = new File(baseDir, "update.sql");
assertFalse(onlyCreate.exists());
assertFalse(onlyDrop.exists());
assertFalse(dropAndCreate.exists());
+ assertFalse(update.exists());
- executeTarget("testantcfg");
+ // allow to test creation of script file + delimiter
+ // + non execution (test will fail if executed because of crappy delimiter)
+ executeTarget("testScriptCreattion");
assertTrue(onlyCreate.exists());
assertTrue(onlyDrop.exists());
assertTrue(dropAndCreate.exists());
+ assertTrue(update.exists());
assertNotNull(TestHelper.findFirstString("drop", dropAndCreate));
assertNotNull(TestHelper.findFirstString("create", dropAndCreate));
-
+ assertNotNull(TestHelper.findFirstString("---", dropAndCreate));
+
assertEquals(null, TestHelper.findFirstString("create", onlyDrop));
assertNotNull(TestHelper.findFirstString("drop", onlyDrop));
-
+
assertEquals(null, TestHelper.findFirstString("drop", onlyCreate));
assertNotNull(TestHelper.findFirstString("create", onlyCreate));
+ assertNotNull(TestHelper.findFirstString("---", onlyCreate));
+
+ assertNotNull(TestHelper.findFirstString("create", update));
+ assertNotNull(TestHelper.findFirstString("---", update));
onlyCreate.delete();
onlyDrop.delete();
dropAndCreate.delete();
+ update.delete();
}
+
+ public void testHbm2DDLUpdateExecution() {
+ cleanupOutputDir();
+ File baseDir = new File(project.getProperty("build.dir"), "topdown");
+ File update1 = new File(baseDir, "update1.sql");
+ File update2 = new File(baseDir, "update2.sql");
+ File onlydrop = new File(baseDir, "onlydrop.sql");
+
+ assertFalse(update1.exists());
+ assertFalse(update2.exists());
+ assertFalse(onlydrop.exists());
+
+ executeTarget("testantcfgUpdateExecuted");
+
+ assertTrue(update1.exists());
+ assertTrue(update2.exists());
+
+ assertNotNull(TestHelper.findFirstString("create", update1));
+ // if first update is executed, the second should be empty
+ assertEquals(0, update2.length());
+
+ update1.delete();
+ update2.delete();
+ onlydrop.delete();
+ }
+
+ public void testHbm2DDLExportExecution() {
+ cleanupOutputDir();
+ File baseDir = new File(project.getProperty("build.dir"), "topdown");
+ File export = new File(baseDir, "export.sql");
+ File update = new File(baseDir, "update.sql");
+ File onlydrop = new File(baseDir, "onlydrop.sql");
+
+ assertFalse(export.exists());
+ assertFalse(update.exists());
+ assertFalse(onlydrop.exists());
+
+
+ executeTarget("testantcfgExportExecuted");
+
+ assertTrue(export.exists());
+ assertTrue(update.exists());
+
+ assertNotNull(TestHelper.findFirstString("create", export));
+ // if export is executed, update should be empty
+ assertEquals(0, update.length());
+
+ export.delete();
+ update.delete();
+ onlydrop.delete();
+ }
+
public void testJDBCConfiguration() {
executeTarget("testantjdbccfg");
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/TestHelper.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/TestHelper.java 2008-06-18 18:04:17 UTC (rev 14781)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/test/TestHelper.java 2008-06-19 08:32:30 UTC (rev 14782)
@@ -255,21 +255,20 @@
}
static public String findFirstString(String string, File file) {
+ String str;
try {
BufferedReader in = new BufferedReader(new FileReader(file) );
- String str;
while ( (str = in.readLine() ) != null ) {
if(str.indexOf(string)>=0) {
- return str;
+ break;
}
}
- in.close();
-
+ in.close();
}
catch (IOException e) {
throw new RuntimeException("trouble with searching in " + file,e);
}
- return null;
+ return str;
}
}
Modified: branches/Branch_3_2/HibernateExt/tools/src/testsupport/anttest-build.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/testsupport/anttest-build.xml 2008-06-18 18:04:17 UTC (rev 14781)
+++ branches/Branch_3_2/HibernateExt/tools/src/testsupport/anttest-build.xml 2008-06-19 08:32:30 UTC (rev 14782)
@@ -23,7 +23,7 @@
<target name="cleanup" description="task used for ensuring cleanup to be done even in the case of test failure" depends="afterCfg2hbm"/>
- <target name="testantcfg">
+ <target name="testScriptCreattion">
<mkdir dir="build/testsupport" />
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" />
@@ -39,14 +39,72 @@
</configuration>
<hbm2java />
- <hbm2ddl drop="false" create="true" export="false" outputfilename="onlycreate.sql" format="true" />
+ <!-- this one is executed, security clean up-->
+ <hbm2ddl drop="true" create="false" export="true" outputfilename="onlydrop.sql" format="true" />
+
+ <!-- allow to test creation of script file + delimiter + non execution (test will fail if executed because of crappy delimiter) -->
+ <hbm2ddl drop="false" create="true" export="false" outputfilename="onlycreate.sql" format="true" delimiter="---"/>
<hbm2ddl drop="true" create="false" export="false" outputfilename="onlydrop.sql" format="true" />
- <hbm2ddl drop="true" create="true" export="false" outputfilename="dropandcreate.sql" format="true" />
+ <hbm2ddl drop="true" create="true" export="false" outputfilename="dropandcreate.sql" format="true" delimiter="---"/>
+ <hbm2ddl export="false" update="true" outputfilename="update.sql" format="true" delimiter="---"/>
+
+ <!-- this one is executed, security clean up, could be easily removed-->
+ <hbm2ddl drop="true" create="false" export="true" outputfilename="onlydrop.sql" format="true" />
<hbm2doc />
</hibernatetool>
</target>
+
+ <target name="testantcfgUpdateExecuted">
+ <mkdir dir="build/testsupport" />
+ <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" />
+ <hibernatetool destdir="${build.dir}/topdown">
+ <classpath>
+ <path location="../../build/testsupport" />
+ </classpath>
+
+ <configuration namingstrategy="org.hibernate.cfg.ImprovedNamingStrategy" entityresolver="DummyEntityResolver">
+ <fileset dir="../test" id="id">
+ <include name="**/*TopDown.hbm.xml" />
+ </fileset>
+ </configuration>
+
+ <hbm2java />
+ <hbm2ddl drop="true" create="false" export="true" outputfilename="onlydrop.sql" format="true" />
+ <hbm2ddl export="true" update="true" outputfilename="update1.sql" format="true" />
+ <hbm2ddl export="false" update="true" outputfilename="update2.sql" format="true" />
+ <hbm2ddl drop="true" create="false" export="true" />
+ <hbm2doc />
+ </hibernatetool>
+
+ </target>
+
+ <target name="testantcfgExportExecuted">
+
+ <mkdir dir="build/testsupport" />
+ <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" />
+ <hibernatetool destdir="${build.dir}/topdown">
+ <classpath>
+ <path location="../../build/testsupport" />
+ </classpath>
+
+ <configuration namingstrategy="org.hibernate.cfg.ImprovedNamingStrategy" entityresolver="DummyEntityResolver">
+ <fileset dir="../test" id="id">
+ <include name="**/*TopDown.hbm.xml" />
+ </fileset>
+ </configuration>
+
+ <hbm2java />
+ <hbm2ddl drop="true" create="false" export="true" outputfilename="onlydrop.sql" format="true" />
+ <hbm2ddl export="true" update="false" outputfilename="export.sql" format="true" />
+ <hbm2ddl export="false" update="true" outputfilename="update.sql" format="true" />
+ <hbm2ddl drop="true" create="false" export="true" />
+ <hbm2doc />
+ </hibernatetool>
+
+ </target>
+
<target name="testantjdbccfg">
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="tasks.classpath" />
<property file="../etc/hibernate.properties" prefix="tools" />
16 years, 6 months