[hibernate-commits] Hibernate SVN: r20769 - core/trunk/core/src/main/java/org/hibernate/cfg.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Mon Oct 4 05:46:17 EDT 2010


Author: epbernard
Date: 2010-10-04 05:46:17 -0400 (Mon, 04 Oct 2010)
New Revision: 20769

Modified:
   core/trunk/core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
   core/trunk/core/src/main/java/org/hibernate/cfg/BinderHelper.java
   core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java
   core/trunk/core/src/main/java/org/hibernate/cfg/Mappings.java
Log:
HHH-5578 centralize specj property discovery

Modified: core/trunk/core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/AnnotationBinder.java	2010-10-04 09:45:41 UTC (rev 20768)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/AnnotationBinder.java	2010-10-04 09:46:17 UTC (rev 20769)
@@ -1418,7 +1418,7 @@
 			 * TODO is @Column mandatory?
 			 * TODO add method support
 			 */
-			if ( System.getProperty( "hibernate.enable_specj_proprietary_syntax" ) != null ) {
+			if ( mappings.isSpecjProprietarySyntaxEnabled() ) {
 				if ( element.isAnnotationPresent( Id.class ) && element.isAnnotationPresent( Column.class ) ) {
 					String columnName = element.getAnnotation( Column.class ).name();
 					for ( XProperty prop : declaringClass.getDeclaredProperties( AccessType.FIELD.getType() ) ) {
@@ -2651,7 +2651,7 @@
 
 		//Make sure that JPA1 key-many-to-one columns are read only tooj
 		boolean hasSpecjManyToOne=false;
-		if ( System.getProperty( "hibernate.enable_specj_proprietary_syntax" ) != null ) {
+		if ( mappings.isSpecjProprietarySyntaxEnabled() ) {
 			String columnName = "";
 			for ( XProperty prop : inferredData.getDeclaringClass()
 					.getDeclaredProperties( AccessType.FIELD.getType() ) ) {

Modified: core/trunk/core/src/main/java/org/hibernate/cfg/BinderHelper.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/BinderHelper.java	2010-10-04 09:45:41 UTC (rev 20768)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/BinderHelper.java	2010-10-04 09:46:17 UTC (rev 20769)
@@ -682,7 +682,7 @@
 		}
 		if ( propertyHolder.isInIdClass() ) {
 			PropertyData pd = mappings.getPropertyAnnotatedWithIdAndToOne( persistentXClass, propertyName );
-			if ( pd == null && System.getProperty( "hibernate.enable_specj_proprietary_syntax" ) != null ) {
+			if ( pd == null && mappings.isSpecjProprietarySyntaxEnabled() ) {
 				pd = mappings.getPropertyAnnotatedWithMapsId( persistentXClass, propertyName );
 			}
 			return pd;

Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java	2010-10-04 09:45:41 UTC (rev 20768)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java	2010-10-04 09:46:17 UTC (rev 20769)
@@ -288,6 +288,7 @@
 	private boolean isValidatorNotPresentLogged;
 	private Map<XClass, Map<String, PropertyData>> propertiesAnnotatedWithMapsId;
 	private Map<XClass, Map<String, PropertyData>> propertiesAnnotatedWithIdAndToOne;
+	private boolean specjProprietarySyntaxEnabled;
 
 
 	protected Configuration(SettingsFactory settingsFactory) {
@@ -358,6 +359,7 @@
 		anyMetaDefs = new HashMap<String, AnyMetaDef>();
 		propertiesAnnotatedWithMapsId = new HashMap<XClass, Map<String, PropertyData>>();
 		propertiesAnnotatedWithIdAndToOne = new HashMap<XClass, Map<String, PropertyData>>();
+		specjProprietarySyntaxEnabled = System.getProperty( "hibernate.enable_specj_proprietary_syntax" ) != null;
 	}
 
 	public EntityTuplizerFactory getEntityTuplizerFactory() {
@@ -3595,6 +3597,10 @@
 			map.put( property.getProperty().getAnnotation( MapsId.class ).value(), property );
 		}
 
+		public boolean isSpecjProprietarySyntaxEnabled() {
+			return specjProprietarySyntaxEnabled;
+		}
+
 		public void addPropertyAnnotatedWithMapsIdSpecj(XClass entityType, PropertyData property, String mapsIdValue) {
 			Map<String, PropertyData> map = propertiesAnnotatedWithMapsId.get( entityType );
 			if ( map == null ) {

Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Mappings.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Mappings.java	2010-10-04 09:45:41 UTC (rev 20768)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/Mappings.java	2010-10-04 09:46:17 UTC (rev 20769)
@@ -735,6 +735,8 @@
 
 	public void addPropertyAnnotatedWithMapsIdSpecj(XClass entityType, PropertyData property, String mapsIdValue);
 
+	public boolean isSpecjProprietarySyntaxEnabled();
+
 	/**
 	 * Should we use the new generator strategy mappings.  This is controlled by the
 	 * {@link Configuration#USE_NEW_ID_GENERATOR_MAPPINGS} setting.



More information about the hibernate-commits mailing list