Author: epbernard
Date: 2007-02-20 14:39:48 -0500 (Tue, 20 Feb 2007)
New Revision: 11224
Modified:
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/EntityTest.java
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/collectionelement/Boy.java
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/indexcoll/AddressBook.java
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java
Log:
Fix some tests issues on MySQL
Modified:
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/EntityTest.java
===================================================================
---
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/EntityTest.java 2007-02-20
19:37:47 UTC (rev 11223)
+++
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/EntityTest.java 2007-02-20
19:39:48 UTC (rev 11224)
@@ -327,7 +327,7 @@
new Date( 05, 06, 21 ),
copyAirFrance.getDepartureDate()
);
- assertEquals( airFrance.getBuyDate(), copyAirFrance.getBuyDate());
+ assertEquals( airFrance.getBuyDate().getTime() / 1000 ,
airFrance.getBuyDate().getTime() / 1000 );
s.delete( copyAirFrance );
tx.commit();
s.close();
Modified:
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/collectionelement/Boy.java
===================================================================
---
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/collectionelement/Boy.java 2007-02-20
19:37:47 UTC (rev 11223)
+++
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/collectionelement/Boy.java 2007-02-20
19:39:48 UTC (rev 11224)
@@ -25,7 +25,7 @@
*/
@Entity
@AttributeOverrides({
- @AttributeOverride( name="characters.element", column =
@Column(name="character") ),
+ @AttributeOverride( name="characters.element", column =
@Column(name="fld_character") ),
@AttributeOverride( name="scorePerNickName.element", column =
@Column(name="fld_score") ),
@AttributeOverride( name="favoriteToys.element.brand.surname", column =
@Column(name = "fld_surname"))}
)
Modified:
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java
===================================================================
---
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java 2007-02-20
19:37:47 UTC (rev 11223)
+++
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java 2007-02-20
19:39:48 UTC (rev 11224)
@@ -122,7 +122,7 @@
public void testType() throws Exception {
Forest f = new Forest();
f.setName( "Broceliande" );
- String description = "C'est une enorme foret enchant�e o� vivais Merlin et
toute la clique";
+ String description = "C'est une enorme foret enchantee ou vivais Merlin et
toute la clique";
f.setLongDescription( description );
Session s;
Transaction tx;
Modified:
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/indexcoll/AddressBook.java
===================================================================
---
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/indexcoll/AddressBook.java 2007-02-20
19:37:47 UTC (rev 11223)
+++
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/indexcoll/AddressBook.java 2007-02-20
19:39:48 UTC (rev 11224)
@@ -42,6 +42,7 @@
@MapKey
@OneToMany(mappedBy = "book", cascade = {CascadeType.MERGE,
CascadeType.PERSIST, CascadeType.REMOVE})
+ @JoinTable(name="AddRegEntry")
public Map<AddressEntryPk, AddressEntry> getEntries() {
return entries;
}
Modified:
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java
===================================================================
---
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java 2007-02-20
19:37:47 UTC (rev 11223)
+++
branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java 2007-02-20
19:39:48 UTC (rev 11224)
@@ -29,11 +29,10 @@
s = openSession();
tx = s.beginTransaction();
s.persist( w );
- tx.commit();
- s.close();
- s = openSession();
- tx = s.beginTransaction();
+ s.flush();
+ s.clear();
+
w = (Wardrobe) s.get( Wardrobe.class, w.getId() );
assertNotNull( w );
assertNotNull( w.getDrawers() );
@@ -44,11 +43,10 @@
s.flush();
d1 = (Drawer) s.merge( d1 );
result.add( d1 );
- tx.commit();
- s.close();
- s = openSession();
- tx = s.beginTransaction();
+ s.flush();
+ s.clear();
+
w = (Wardrobe) s.get( Wardrobe.class, w.getId() );
assertNotNull( w );
assertNotNull( w.getDrawers() );
@@ -58,7 +56,8 @@
s.delete( result.get( 0 ) );
s.delete( result.get( 1 ) );
s.delete( w );
- tx.commit();
+ s.flush();
+ tx.rollback();
s.close();
}
@@ -79,11 +78,10 @@
s.persist( d1 );
s.persist( d2 );
s.persist( w );
- tx.commit();
- s.close();
- s = openSession();
- tx = s.beginTransaction();
+ s.flush();
+ s.clear();
+
d = (Drawer) s.get( Drawer.class, d.getId() );
assertNotNull( d );
assertNotNull( d.getDresses() );
@@ -94,11 +92,10 @@
s.flush();
d1 = (Dress) s.merge( d1 );
result.add( d1 );
- tx.commit();
- s.close();
- s = openSession();
- tx = s.beginTransaction();
+ s.flush();
+ s.clear();
+
d = (Drawer) s.get( Drawer.class, d.getId() );
assertNotNull( d );
assertNotNull( d.getDresses() );
@@ -108,7 +105,8 @@
s.delete( result.get( 0 ) );
s.delete( result.get( 1 ) );
s.delete( d );
- tx.commit();
+ s.flush();
+ tx.rollback();
s.close();
}
@@ -140,24 +138,29 @@
s.persist( v1 );
s.persist( v2 );
s.persist( v4 );
- tx.commit();
+
+ s.flush();
s.clear();
- tx = s.beginTransaction();
+
hibernate = (Software) s.get( Software.class, "Hibernate" );
assertEquals( 3, hibernate.getVersions().size() );
assertEquals( "1.0", hibernate.getVersions().get( "HumbaHumba"
).getNumber() );
assertEquals( "2.0", hibernate.getVersions().get( "Copacabana"
).getNumber() );
hibernate.getVersions().remove( v4.getCodeName() );
- tx.commit();
+
+ s.flush();
s.clear();
- tx = s.beginTransaction();
+
hibernate = (Software) s.get( Software.class, "Hibernate" );
assertEquals( "So effect on collection changes", 3,
hibernate.getVersions().size() );
for ( Version v : hibernate.getVersions().values() ) {
s.delete( v );
}
s.delete( hibernate );
- tx.commit();
+
+ s.flush();
+
+ tx.rollback();
s.close();
}
@@ -183,22 +186,26 @@
book.getEntries().put( helene, heleneEntry );
book.getEntries().put( primeMinister, primeMinisterEntry );
s.persist( book );
- tx.commit();
+
+ s.flush();
s.clear();
- tx = s.beginTransaction();
+
book = (AddressBook) s.get( AddressBook.class, book.getId() );
assertEquals( 2, book.getEntries().size() );
assertEquals( heleneEntry.getCity(), book.getEntries().get( helene ).getCity() );
AddressEntryPk fake = new AddressEntryPk( "Fake", "Fake" );
book.getEntries().put( fake, primeMinisterEntry );
- tx.commit();
+
+ s.flush();
s.clear();
- tx = s.beginTransaction();
+
book = (AddressBook) s.get( AddressBook.class, book.getId() );
assertEquals( 2, book.getEntries().size() );
assertNull( book.getEntries().get( fake ) );
s.delete( book );
- tx.commit();
+
+ s.flush();
+ tx.rollback();
s.close();
}
@@ -233,6 +240,7 @@
book.getEntries().put( helene, heleneEntry );
book.getEntries().put( primeMinister, primeMinisterEntry );
s.persist( book );
+
s.flush();
s.clear();
@@ -268,22 +276,24 @@
book.getEntries().put( helene, heleneEntry );
book.getEntries().put( primeMinister, primeMinisterEntry );
s.persist( book );
- tx.commit();
+
+ s.flush();
s.clear();
- tx = s.beginTransaction();
+
book = (AddressBook) s.get( AddressBook.class, book.getId() );
assertEquals( 2, book.getLastNameEntries().size() );
assertEquals( heleneEntry.getCity(), book.getLastNameEntries().get( "Michau"
).getCity() );
AddressEntryPk fake = new AddressEntryPk( "Fake", "Fake" );
book.getEntries().put( fake, primeMinisterEntry );
- tx.commit();
+
+ s.flush();
s.clear();
- tx = s.beginTransaction();
+
book = (AddressBook) s.get( AddressBook.class, book.getId() );
assertEquals( 2, book.getEntries().size() );
assertNull( book.getEntries().get( fake ) );
s.delete( book );
- tx.commit();
+ tx.rollback();
s.close();
}
@@ -299,11 +309,10 @@
lemonde.setName( "Lemonde" );
lemonde.getNews().put( airplane.getTitle(), airplane );
s.persist( lemonde );
- s.getTransaction().commit();
+ s.flush();
s.clear();
- Transaction tx = s.beginTransaction();
lemonde = (Newspaper) s.get( Newspaper.class, lemonde.getId() );
assertEquals( 1, lemonde.getNews().size() );
News news = lemonde.getNews().get( airplane.getTitle() );
@@ -311,8 +320,8 @@
assertEquals( airplane.getTitle(), news.getTitle() );
s.delete( lemonde );
s.delete( news );
- tx.commit();
+ s.getTransaction().rollback();
s.close();
}
@@ -328,11 +337,10 @@
schwartz.setName( "Schwartz" );
schwartz.getProvidedNews().put( hibernate1.getId(), hibernate1 );
s.persist( schwartz );
- s.getTransaction().commit();
+ s.flush();
s.clear();
- Transaction tx = s.beginTransaction();
schwartz = (PressReleaseAgency) s.get( PressReleaseAgency.class, schwartz.getId() );
assertEquals( 1, schwartz.getProvidedNews().size() );
News news = schwartz.getProvidedNews().get( hibernate1.getId() );
@@ -340,8 +348,8 @@
assertEquals( hibernate1.getTitle(), news.getTitle() );
s.delete( schwartz );
s.delete( news );
- tx.commit();
+ s.getTransaction().rollback();
s.close();
}
@@ -354,17 +362,16 @@
Painting famille = new Painting( "La Famille du Saltimbanque",
"Picasso", 50, 20 );
picasso.getPaintings().put( "La Famille du Saltimbanque", famille );
s.persist( picasso );
- tx.commit();
- s.close();
- s = openSession();
- tx = s.beginTransaction();
+ s.flush();
+ s.clear();
+
picasso = (Painter) s.get( Painter.class, picasso.getId() );
Painting painting = picasso.getPaintings().get( famille.getName() );
assertNotNull( painting );
assertEquals( painting.getName(), famille.getName() );
s.delete( picasso );
- tx.commit();
+ tx.rollback();
s.close();
}
@@ -384,6 +391,7 @@
s.persist( key );
s.persist( atm );
s.persist( atm2 );
+
s.flush();
s.clear();
@@ -412,6 +420,7 @@
entry.setDirectory( ad );
s.persist( entry );
book.getDirectoryEntries().put( ad, entry );
+
s.flush();
s.clear();
@@ -431,6 +440,7 @@
atm.composition.put( o2, 94.3 );
s.persist( o2 );
s.persist( atm );
+
s.flush();
s.clear();
@@ -455,8 +465,10 @@
training.getTrainees().put( "Jim", trainee );
training.getTrainees().put( "Emmanuel", trainee2 );
s.persist( training );
+
s.flush();
s.clear();
+
training = (Training) s.get( Training.class, training.getId() );
assertEquals( "Emmanuel", training.getTrainees().firstKey() );
assertEquals( "Jim", training.getTrainees().lastKey() );
@@ -478,9 +490,10 @@
hibernate.addVersion( v1 );
s.persist( hibernate );
s.persist( v1 );
- tx.commit();
+
+ s.flush();
s.clear();
- tx = s.beginTransaction();
+
hibernate = (Software) s.get( Software.class, "Hibernate" );
assertEquals(1, hibernate.getVersions().size() );
Version v2 = new Version();
@@ -489,15 +502,16 @@
v2.setSoftware( hibernate );
hibernate.addVersion( v2 );
assertEquals( "One loaded persisted version, and one just added", 2,
hibernate.getVersions().size() );
- tx.commit();
+
+ s.flush();
s.clear();
- tx = s.beginTransaction();
+
hibernate = (Software) s.get( Software.class, "Hibernate" );
for ( Version v : hibernate.getVersions().values() ) {
s.delete( v );
}
s.delete( hibernate );
- tx.commit();
+ tx.rollback();
s.close();
}