HHH-5578 centralize specj property discovery

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@20769 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Emmanuel Bernard 2010-10-04 09:46:17 +00:00
parent c21ea5e3e1
commit e2f6b83754
4 changed files with 11 additions and 3 deletions

View File

@ -1418,7 +1418,7 @@ private static int addProperty(
* 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 @@ private static void bindManyToOne(
//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() ) ) {

View File

@ -682,7 +682,7 @@ static PropertyData getPropertyOverriddenByMapperOrMapsId(
}
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;

View File

@ -288,6 +288,7 @@ public class Configuration implements Serializable {
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 @@ protected void reset() {
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 @@ public void addPropertyAnnotatedWithMapsId(XClass entityType, PropertyData prope
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 ) {

View File

@ -735,6 +735,8 @@ public PropertyReference(String referencedClass, String propertyName, boolean un
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.