Hibernate SVN: r11228 - branches/Branch_3_2/HibernateExt/validator/src/test/org/hibernate/validator/test.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-02-20 19:02:28 -0500 (Tue, 20 Feb 2007)
New Revision: 11228
Modified:
branches/Branch_3_2/HibernateExt/validator/src/test/org/hibernate/validator/test/EmailTest.java
Log:
HV-3 empty email string should pass
Modified: branches/Branch_3_2/HibernateExt/validator/src/test/org/hibernate/validator/test/EmailTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/validator/src/test/org/hibernate/validator/test/EmailTest.java 2007-02-21 00:00:37 UTC (rev 11227)
+++ branches/Branch_3_2/HibernateExt/validator/src/test/org/hibernate/validator/test/EmailTest.java 2007-02-21 00:02:28 UTC (rev 11228)
@@ -13,7 +13,9 @@
public void testEmail() throws Exception {
userValidator = new ClassValidator<User>( User.class );
isRightEmail( "emmanuel(a)hibernate.org" );
- isWrongEmail( "emmanuel.hibernate.org" );
+ isRightEmail( "" );
+ isRightEmail( null );
+ isWrongEmail( "emmanuel.hibernate.org" );
isRightEmail( "emmanuel@hibernate" );
isRightEmail( "emma-n_uel@hibernate" );
isWrongEmail( "emma nuel(a)hibernate.org" );
18 years, 2 months
Hibernate SVN: r11227 - branches/Branch_3_2/HibernateExt/validator/src/java/org/hibernate/validator.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-02-20 19:00:37 -0500 (Tue, 20 Feb 2007)
New Revision: 11227
Modified:
branches/Branch_3_2/HibernateExt/validator/src/java/org/hibernate/validator/EmailValidator.java
Log:
HV-3
Modified: branches/Branch_3_2/HibernateExt/validator/src/java/org/hibernate/validator/EmailValidator.java
===================================================================
--- branches/Branch_3_2/HibernateExt/validator/src/java/org/hibernate/validator/EmailValidator.java 2007-02-20 21:32:32 UTC (rev 11226)
+++ branches/Branch_3_2/HibernateExt/validator/src/java/org/hibernate/validator/EmailValidator.java 2007-02-21 00:00:37 UTC (rev 11227)
@@ -20,7 +20,8 @@
if ( value == null ) return true;
if ( !( value instanceof String ) ) return false;
String string = (String) value;
- Matcher m = pattern.matcher( string );
+ if ( string.length() == 0 ) return true;
+ Matcher m = pattern.matcher( string );
return m.matches();
}
18 years, 2 months
Hibernate SVN: r11226 - branches/Branch_3_2/HibernateExt/entitymanager/src/java/org/hibernate/ejb.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-02-20 16:32:32 -0500 (Tue, 20 Feb 2007)
New Revision: 11226
Modified:
branches/Branch_3_2/HibernateExt/entitymanager/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
Log:
Style
Modified: branches/Branch_3_2/HibernateExt/entitymanager/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
===================================================================
--- branches/Branch_3_2/HibernateExt/entitymanager/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2007-02-20 20:55:29 UTC (rev 11225)
+++ branches/Branch_3_2/HibernateExt/entitymanager/src/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2007-02-20 21:32:32 UTC (rev 11226)
@@ -582,7 +582,7 @@
}
public void throwPersistenceException(PersistenceException e) {
- if ( ! ( e instanceof NoResultException || ( e instanceof NonUniqueResultException ) ) ) {
+ if ( ! ( e instanceof NoResultException || e instanceof NonUniqueResultException ) ) {
try {
markAsRollback();
}
18 years, 2 months
Hibernate SVN: r11225 - branches/Branch_3_2/HibernateExt/jpa-api/src/javax/persistence.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-02-20 15:55:29 -0500 (Tue, 20 Feb 2007)
New Revision: 11225
Modified:
branches/Branch_3_2/HibernateExt/jpa-api/src/javax/persistence/Query.java
Log:
JavaDoc fixing
Modified: branches/Branch_3_2/HibernateExt/jpa-api/src/javax/persistence/Query.java
===================================================================
--- branches/Branch_3_2/HibernateExt/jpa-api/src/javax/persistence/Query.java 2007-02-20 19:39:48 UTC (rev 11224)
+++ branches/Branch_3_2/HibernateExt/jpa-api/src/javax/persistence/Query.java 2007-02-20 20:55:29 UTC (rev 11225)
@@ -9,138 +9,140 @@
/**
* Interface used to control query execution.
*/
-public interface Query {
- /**
- * Execute the query and return the query results as a List.
- *
- * @return a list of the results
- * @throws IllegalStateException f called for a Java Persistence query language UPDATE or DELETE statement
- */
- public List getResultList();
+public interface Query
+{
+ /**
+ * Execute the query and return the query results as a List.
+ *
+ * @return a list of the results
+ * @throws IllegalStateException f called for a Java Persistence query language UPDATE or DELETE statement
+ */
+ public List getResultList();
- /**
- * Execute a query that returns a single result.
- *
- * @return the result
- * @throws EntityNotFoundException if there is no result
- * @throws NonUniqueResultException if more than one resul
- * @throws IllegalStateException f called for a Java Persistence query language UPDATE or DELETE statement
- */
- public Object getSingleResult();
+ /**
+ * Execute a SELECT query that returns a single result.
+ *
+ * @return the result
+ * @throws NoResultException if there is no result
+ * @throws NonUniqueResultException if more than one result
+ * @throws IllegalStateException if called for a Java
+ * Persistence query language UPDATE or DELETE statement
+ */
+ public Object getSingleResult();
- /**
- * Execute an update or delete statement.
- *
- * @return the number of entities updated or deleted
- * @throws IllegalStateException if called for a Java Persistence query language SELECT statement
- * @throws TransactionRequiredException if there is no transaction
- */
- public int executeUpdate();
+ /**
+ * Execute an update or delete statement.
+ *
+ * @return the number of entities updated or deleted
+ * @throws IllegalStateException if called for a Java Persistence query language SELECT statement
+ * @throws TransactionRequiredException if there is no transaction
+ */
+ public int executeUpdate();
- /**
- * Set the maximum number of results to retrieve.
- *
- * @param maxResult
- * @return the same query instance
- * @throws IllegalArgumentException if argument is negative
- */
- public Query setMaxResults(int maxResult);
+ /**
+ * Set the maximum number of results to retrieve.
+ *
+ * @param maxResult
+ * @return the same query instance
+ * @throws IllegalArgumentException if argument is negative
+ */
+ public Query setMaxResults(int maxResult);
- /**
- * Set the position of the first result to retrieve.
- *
- * @param startPosition position of the first result, numbered from 0
- * @return the same query instance
- * @throws IllegalArgumentException if argument is negative
- */
- public Query setFirstResult(int startPosition);
+ /**
+ * Set the position of the first result to retrieve.
+ *
+ * @param startPosition position of the first result, numbered from 0
+ * @return the same query instance
+ * @throws IllegalArgumentException if argument is negative
+ */
+ public Query setFirstResult(int startPosition);
- /**
- * Set an implementation-specific hint. If the hint name is not recognized, it is silently
- * ignored.
- *
- * @param hintName
- * @param value
- * @return the same query instance
- * @throws IllegalArgumentException if the second argument is not valid for the implementation
- */
- public Query setHint(String hintName, Object value);
+ /**
+ * Set an implementation-specific hint. If the hint name is not recognized, it is silently
+ * ignored.
+ *
+ * @param hintName
+ * @param value
+ * @return the same query instance
+ * @throws IllegalArgumentException if the second argument is not valid for the implementation
+ */
+ public Query setHint(String hintName, Object value);
- /**
- * Bind an argument to a named parameter.
- *
- * @param name the parameter name
- * @param value
- * @return the same query instance
- * @throws IllegalArgumentException if parameter name does not correspond to parameter in query
- * string or argument is of incorrect type
- */
- public Query setParameter(String name, Object value);
+ /**
+ * Bind an argument to a named parameter.
+ *
+ * @param name the parameter name
+ * @param value
+ * @return the same query instance
+ * @throws IllegalArgumentException if parameter name does not correspond to parameter in query
+ * string or argument is of incorrect type
+ */
+ public Query setParameter(String name, Object value);
- /**
- * Bind an instance of java.util.Date to a named parameter.
- *
- * @param name
- * @param value
- * @param temporalType
- * @return the same query instance
- * @throws IllegalArgumentException if parameter name does not correspond to parameter in query
- * string
- */
- public Query setParameter(String name, Date value, TemporalType temporalType);
+ /**
+ * Bind an instance of java.util.Date to a named parameter.
+ *
+ * @param name
+ * @param value
+ * @param temporalType
+ * @return the same query instance
+ * @throws IllegalArgumentException if parameter name does not correspond to parameter in query
+ * string
+ */
+ public Query setParameter(String name, Date value, TemporalType temporalType);
- /**
- * Bind an instance of java.util.Calendar to a named parameter.
- *
- * @param name
- * @param value
- * @param temporalType
- * @return the same query instance
- * @throws IllegalArgumentException if parameter name does not correspond to parameter in query
- * string
- */
- public Query setParameter(String name, Calendar value, TemporalType temporalType);
+ /**
+ * Bind an instance of java.util.Calendar to a named parameter.
+ *
+ * @param name
+ * @param value
+ * @param temporalType
+ * @return the same query instance
+ * @throws IllegalArgumentException if parameter name does not correspond to parameter in query
+ * string
+ */
+ public Query setParameter(String name, Calendar value, TemporalType temporalType);
- /**
- * Bind an argument to a positional parameter.
- *
- * @param position
- * @param value
- * @return the same query instance
- * @throws IllegalArgumentException if position does not correspond to positional parameter of
- * query or argument is of incorrect type
- */
- public Query setParameter(int position, Object value);
+ /**
+ * Bind an argument to a positional parameter.
+ *
+ * @param position
+ * @param value
+ * @return the same query instance
+ * @throws IllegalArgumentException if position does not correspond to positional parameter of
+ * query or argument is of incorrect type
+ */
+ public Query setParameter(int position, Object value);
- /**
- * Bind an instance of java.util.Date to a positional parameter.
- *
- * @param position
- * @param value
- * @param temporalType
- * @return the same query instance
- * @throws IllegalArgumentException if position does not correspond to positional parameter of
- * query
- */
- public Query setParameter(int position, Date value, TemporalType temporalType);
+ /**
+ * Bind an instance of java.util.Date to a positional parameter.
+ *
+ * @param position
+ * @param value
+ * @param temporalType
+ * @return the same query instance
+ * @throws IllegalArgumentException if position does not correspond to positional parameter of
+ * query
+ */
+ public Query setParameter(int position, Date value, TemporalType temporalType);
- /**
- * Bind an instance of java.util.Calendar to a positional parameter.
- *
- * @param position
- * @param value
- * @param temporalType
- * @return the same query instance } correspond to positional parameter of query
- */
- public Query setParameter(int position, Calendar value, TemporalType temporalType);
+ /**
+ * Bind an instance of java.util.Calendar to a positional parameter.
+ *
+ * @param position
+ * @param value
+ * @param temporalType
+ * @return the same query instance } correspond to positional parameter of query
+ */
+ public Query setParameter(int position, Calendar value, TemporalType temporalType);
- /**
- * Set the flush mode type to be used for the query execution.
- * The flush mode type applies to the query regardless of the
- * flush mode type in use for the entity manager.
- *
- * @param flushMode
- */
- public Query setFlushMode(FlushModeType flushMode);
+ /**
+ * Set the flush mode type to be used for the query execution.
+ * The flush mode type applies to the query regardless of the
+ * flush mode type in use for the entity manager.
+ *
+ * @param flushMode
+ */
+ public Query setFlushMode(FlushModeType flushMode);
}
\ No newline at end of file
18 years, 2 months
Hibernate SVN: r11224 - in branches/Branch_3_2/HibernateExt/annotations/src/test/org/hibernate/test/annotations: collectionelement and 2 other directories.
by hibernate-commits@lists.jboss.org
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();
}
18 years, 2 months
Hibernate SVN: r11223 - in branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg: annotations and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-02-20 14:37:47 -0500 (Tue, 20 Feb 2007)
New Revision: 11223
Modified:
branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3JoinColumn.java
branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/TableBinder.java
Log:
ANN-560 Quoting issues: if source is quoted, quote the result and unquote the source first
Modified: branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3JoinColumn.java
===================================================================
--- branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3JoinColumn.java 2007-02-20 19:35:20 UTC (rev 11222)
+++ branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/Ejb3JoinColumn.java 2007-02-20 19:37:47 UTC (rev 11223)
@@ -10,13 +10,13 @@
import org.hibernate.AnnotationException;
import org.hibernate.MappingException;
+import org.hibernate.annotations.common.util.StringHelper;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Join;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.Value;
-import org.hibernate.util.StringHelper;
/**
* Wrap state of an EJB3 @JoinColumn annotation
@@ -272,27 +272,51 @@
);
boolean mappedBySide = mappedByTableName != null || mappedByPropertyName != null;
boolean ownerSide = getPropertyName() != null;
+
+ Boolean isRefColumnQuoted = StringHelper.isQuoted( logicalReferencedColumn );
+ String unquotedLogicalReferenceColumn = isRefColumnQuoted ?
+ StringHelper.unquote( logicalReferencedColumn ) :
+ logicalReferencedColumn;
+
if ( mappedBySide ) {
+ String unquotedMappedbyTable = StringHelper.unquote( mappedByTableName );
columnName = getMappings().getNamingStrategy().foreignKeyColumnName(
mappedByPropertyName,
- mappedByEntityName, mappedByTableName,
- logicalReferencedColumn
+ mappedByEntityName,
+ unquotedMappedbyTable,
+ unquotedLogicalReferenceColumn
);
- //columnName = ( defaultColumnHeader == null ? getPropertyName() : defaultColumnHeader ) + "_" + logicalReferencedColumn;
+ //one element was quoted so we quote
+ if ( isRefColumnQuoted || StringHelper.isQuoted( mappedByTableName ) ) {
+ columnName = StringHelper.quote( columnName );
+ }
}
else if ( ownerSide ) {
+ String logicalTableName = getMappings().getLogicalTableName( referencedEntity.getTable() );
+ String unquotedLogicalTableName = StringHelper.unquote( logicalTableName );
columnName = getMappings().getNamingStrategy().foreignKeyColumnName(
getPropertyName(),
- referencedEntity.getEntityName(), getMappings().getLogicalTableName( referencedEntity.getTable() ),
- logicalReferencedColumn
+ referencedEntity.getEntityName(),
+ unquotedLogicalTableName,
+ unquotedLogicalReferenceColumn
);
+ //one element was quoted so we quote
+ if ( isRefColumnQuoted || StringHelper.isQuoted( logicalTableName ) ) {
+ columnName = StringHelper.quote( columnName );
+ }
}
else {
//is an intra-entity hierarchy table join so copy the name by default
+ String logicalTableName = getMappings().getLogicalTableName( referencedEntity.getTable() );
+ String unquotedLogicalTableName = StringHelper.unquote( logicalTableName );
columnName = getMappings().getNamingStrategy().joinKeyColumnName(
- logicalReferencedColumn,
- getMappings().getLogicalTableName( referencedEntity.getTable() )
+ unquotedLogicalReferenceColumn,
+ unquotedLogicalTableName
);
+ //one element was quoted so we quote
+ if ( isRefColumnQuoted || StringHelper.isQuoted( logicalTableName ) ) {
+ columnName = StringHelper.quote( columnName );
+ }
}
//yuk side effect on an implicit column
setLogicalColumnName( columnName );
@@ -329,8 +353,13 @@
protected void addColumnBinding(SimpleValue value) {
if ( StringHelper.isEmpty( mappedBy ) ) {
+ String unquotedLogColName = StringHelper.unquote( getLogicalColumnName() );
+ String unquotedRefColumn = StringHelper.unquote( getReferencedColumn() );
String logicalColumnName = getMappings().getNamingStrategy()
- .logicalCollectionColumnName( getLogicalColumnName(), getPropertyName(), getReferencedColumn() );
+ .logicalCollectionColumnName( unquotedLogColName, getPropertyName(), unquotedRefColumn );
+ if ( StringHelper.isQuoted( getLogicalColumnName() ) || StringHelper.isQuoted( getLogicalColumnName() ) ) {
+ logicalColumnName = StringHelper.quote( logicalColumnName );
+ }
getMappings().addColumnBinding( logicalColumnName, getMappingColumn(), value.getTable() );
}
}
@@ -427,14 +456,6 @@
}
}
- public void setMappedByPropertyName(String mappedByPropertyName) {
- this.mappedByPropertyName = mappedByPropertyName;
- }
-
- public void setMappedByTableName(String mappedByTableName) {
- this.mappedByTableName = mappedByTableName;
- }
-
public static Ejb3JoinColumn[] buildJoinTableJoinColumns(
JoinColumn[] annJoins, Map<String, Join> secondaryTables,
PropertyHolder propertyHolder, String propertyName, String mappedBy, ExtendedMappings mappings
Modified: branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/TableBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/TableBinder.java 2007-02-20 19:35:20 UTC (rev 11222)
+++ branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/TableBinder.java 2007-02-20 19:37:47 UTC (rev 11223)
@@ -11,6 +11,7 @@
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.annotations.Index;
+import org.hibernate.annotations.common.util.StringHelper;
import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.Ejb3JoinColumn;
import org.hibernate.cfg.ExtendedMappings;
@@ -25,7 +26,6 @@
import org.hibernate.mapping.Table;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
-import org.hibernate.util.StringHelper;
/**
* Table related operations
@@ -43,8 +43,8 @@
String constraints;
Table denormalizedSuperTable;
ExtendedMappings mappings;
- private Table ownerEntityTable;
- private Table associatedEntityTable;
+ private String ownerEntityTable;
+ private String associatedEntityTable;
private String propertyName;
private String ownerEntity;
private String associatedEntity;
@@ -88,22 +88,35 @@
// only bind association table currently
public Table bind() {
//logicalName only accurate for assoc table...
+ String unquotedOwnerTable = StringHelper.unquote( ownerEntityTable );
+ String unquotedAssocTable = StringHelper.unquote( associatedEntityTable );
+
String logicalName = mappings.getNamingStrategy()
.logicalCollectionTableName(
name,
- ownerEntityTable == null ? null : ownerEntityTable.getName(), //we remove potential quotes
- associatedEntityTable == null ? null : associatedEntityTable.getName(), //we remove potential quotes
+ unquotedOwnerTable,
+ unquotedAssocTable,
propertyName );
- String extendedName = name != null ?
- mappings.getNamingStrategy().tableName( name ) :
- mappings.getNamingStrategy()
- .collectionTableName(
- ownerEntity,
- ownerEntityTable == null ? null : ownerEntityTable.getName(), //we remove potential quotes
- associatedEntity,
- associatedEntityTable == null ? null : associatedEntityTable.getName(), //we remove potential quotes
- propertyName
- );
+ if ( StringHelper.isQuoted( ownerEntityTable ) || StringHelper.isQuoted( associatedEntityTable ) ) {
+ logicalName = StringHelper.quote( logicalName );
+ }
+ String extendedName;
+ if ( name != null ) {
+ extendedName = mappings.getNamingStrategy().tableName( name );
+ }
+ else {
+ extendedName = mappings.getNamingStrategy()
+ .collectionTableName(
+ ownerEntity,
+ unquotedOwnerTable,
+ associatedEntity,
+ unquotedAssocTable,
+ propertyName
+ );
+ if ( StringHelper.isQuoted( ownerEntityTable ) || StringHelper.isQuoted( associatedEntityTable ) ) {
+ extendedName = StringHelper.quote( extendedName );
+ }
+ }
return fillTable(
schema, catalog,
extendedName, logicalName, isAbstract, uniqueConstraints, constraints,
@@ -367,9 +380,9 @@
String propertyName
) {
this.ownerEntity = ownerEntity;
- this.ownerEntityTable = ownerEntityTable != null ? new Table(ownerEntityTable) : null;
+ this.ownerEntityTable = ownerEntityTable;
this.associatedEntity = associatedEntity;
- this.associatedEntityTable = associatedEntityTable != null ? new Table(associatedEntityTable) : null;
+ this.associatedEntityTable = associatedEntityTable;
this.propertyName = propertyName;
this.name = null;
}
18 years, 2 months
Hibernate SVN: r11222 - branches/Branch_3_2/HibernateExt/annotations/src/test.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-02-20 14:35:20 -0500 (Tue, 20 Feb 2007)
New Revision: 11222
Modified:
branches/Branch_3_2/HibernateExt/annotations/src/test/hibernate.properties
Log:
config for MySQL
Modified: branches/Branch_3_2/HibernateExt/annotations/src/test/hibernate.properties
===================================================================
--- branches/Branch_3_2/HibernateExt/annotations/src/test/hibernate.properties 2007-02-20 19:33:02 UTC (rev 11221)
+++ branches/Branch_3_2/HibernateExt/annotations/src/test/hibernate.properties 2007-02-20 19:35:20 UTC (rev 11222)
@@ -45,7 +45,7 @@
#hibernate.connection.driver_class com.mysql.jdbc.Driver
#hibernate.connection.url jdbc:mysql:///test
#hibernate.connection.username emmanuel
-#hibernate.connection.password
+#hibernate.connection.password hibernate
## Oracle
18 years, 2 months
Hibernate SVN: r11221 - branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-02-20 14:33:02 -0500 (Tue, 20 Feb 2007)
New Revision: 11221
Modified:
branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/EntityBinder.java
Log:
ANN-559 filter unknown leads to NPEs
Modified: branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/EntityBinder.java
===================================================================
--- branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/EntityBinder.java 2007-02-20 19:29:20 UTC (rev 11220)
+++ branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/EntityBinder.java 2007-02-20 19:33:02 UTC (rev 11221)
@@ -48,6 +48,7 @@
import org.hibernate.cfg.PropertyHolder;
import org.hibernate.engine.Versioning;
import org.hibernate.engine.ExecuteUpdateResultCheckStyle;
+import org.hibernate.engine.FilterDefinition;
import org.hibernate.mapping.DependantValue;
import org.hibernate.mapping.Join;
import org.hibernate.mapping.PersistentClass;
@@ -260,7 +261,8 @@
String filterName = filter.getKey();
String cond = filter.getValue();
if ( BinderHelper.isDefault( cond ) ) {
- cond = mappings.getFilterDefinition( filterName ).getDefaultFilterCondition();
+ FilterDefinition definition = mappings.getFilterDefinition( filterName );
+ cond = definition == null ? null : definition.getDefaultFilterCondition();
if ( StringHelper.isEmpty( cond ) ) {
throw new AnnotationException(
"no filter condition found for filter " + filterName + " in " + this.name
18 years, 2 months
Hibernate SVN: r11220 - branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-02-20 14:29:20 -0500 (Tue, 20 Feb 2007)
New Revision: 11220
Modified:
branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection/EJB3OverridenAnnotationReader.java
Log:
Ignore primitive classes when checking for orphan properties
Modified: branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection/EJB3OverridenAnnotationReader.java
===================================================================
--- branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection/EJB3OverridenAnnotationReader.java 2007-02-19 19:43:25 UTC (rev 11219)
+++ branches/Branch_3_2/HibernateExt/annotations/src/java/org/hibernate/cfg/annotations/reflection/EJB3OverridenAnnotationReader.java 2007-02-20 19:29:20 UTC (rev 11220)
@@ -369,7 +369,7 @@
clazz = ReflectHelper.classForName( className, this.getClass() );
}
catch (ClassNotFoundException e) {
- throw new AssertionFailure("Unable to load class " + className );
+ return; //a primitive type most likely
}
Element element = tree != null ? tree.element( "attributes" ) : null;
//put entity.attributes elements
18 years, 2 months
Hibernate SVN: r11219 - branches/Branch_3_2/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ejb3configuration.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-02-19 14:43:25 -0500 (Mon, 19 Feb 2007)
New Revision: 11219
Modified:
branches/Branch_3_2/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ejb3configuration/ProgrammaticConfTest.java
Log:
clean up after me...
Modified: branches/Branch_3_2/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ejb3configuration/ProgrammaticConfTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ejb3configuration/ProgrammaticConfTest.java 2007-02-19 19:36:40 UTC (rev 11218)
+++ branches/Branch_3_2/HibernateExt/entitymanager/src/test/org/hibernate/ejb/test/ejb3configuration/ProgrammaticConfTest.java 2007-02-19 19:43:25 UTC (rev 11219)
@@ -33,6 +33,7 @@
em.flush();
assertNotNull( em.find(Cat.class, cat.getId() ) );
em.getTransaction().rollback();
+ emf.close();
}
protected Properties getProperties() throws IOException {
18 years, 2 months