[hibernate-commits] Hibernate SVN: r18563 - in core/trunk: core/src/main/java/org/hibernate/cfg and 1 other directory.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Jan 15 07:57:47 EST 2010


Author: epbernard
Date: 2010-01-15 07:57:47 -0500 (Fri, 15 Jan 2010)
New Revision: 18563

Modified:
   core/trunk/annotations/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationActivator.java
   core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java
Log:
HHH-4807 only switch CHECK_NULLABILITY's default if Bean Validation is in the class path

Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationActivator.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationActivator.java	2010-01-15 12:53:35 UTC (rev 18562)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationActivator.java	2010-01-15 12:57:47 UTC (rev 18563)
@@ -28,18 +28,12 @@
 
 	public static void activateBeanValidation(EventListeners eventListeners, Properties properties) {
 		Set<ValidationMode> modes = ValidationMode.getModes( properties.get( MODE_PROPERTY ) );
-		if ( modes.contains( ValidationMode.NONE ) ) return;
-		//de-activate not-null tracking at the core level when Bean Validation is on unless the user really ask for it
-		if ( properties.getProperty( Environment.CHECK_NULLABILITY ) == null ) {
-			properties.setProperty( Environment.CHECK_NULLABILITY, "false" );
-		}
 
 		try {
 			//load Validation
 			ReflectHelper.classForName( BV_DISCOVERY_CLASS, BeanValidationActivator.class );
 		}
 		catch ( ClassNotFoundException e ) {
-
 			if ( modes.contains( ValidationMode.CALLBACK ) ) {
 				throw new HibernateException( "Bean Validation not available in the class path but required in " + MODE_PROPERTY );
 			}
@@ -48,6 +42,16 @@
 				return;
 			}
 		}
+
+		//de-activate not-null tracking at the core level when Bean Validation
+		// is present unless the user really asks for it
+		//Note that if BV is not present, the behavior is backward compatible
+		if ( properties.getProperty( Environment.CHECK_NULLABILITY ) == null ) {
+			properties.setProperty( Environment.CHECK_NULLABILITY, "false" );
+		}
+
+		if ( modes.contains( ValidationMode.NONE ) ) return;
+
 		try {
 			Class<?> activator = ReflectHelper.classForName( TYPE_SAFE_ACTIVATOR_CLASS, BeanValidationActivator.class );
 			Method activateBeanValidation =

Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java	2010-01-15 12:53:35 UTC (rev 18562)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java	2010-01-15 12:57:47 UTC (rev 18563)
@@ -509,7 +509,8 @@
 	/**
 	 * Enable nullability checking.
 	 * Raises an exception if a property marked as not-null is null.
-	 * Default to true.
+	 * Default to false if Bean Validation is present in the classpath and Hibernate Annotations is used,
+	 * true otherwise.
 	 */
 	public static final String CHECK_NULLABILITY = "hibernate.check_nullability";
 



More information about the hibernate-commits mailing list