[hibernate-commits] Hibernate SVN: r17919 - in annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg: annotations and 1 other directory.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Thu Nov 5 00:21:01 EST 2009
Author: stliu
Date: 2009-11-05 00:21:01 -0500 (Thu, 05 Nov 2009)
New Revision: 17919
Modified:
annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/Ejb3JoinColumn.java
annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations/TableBinder.java
Log:
JBPAPP-3060 ANN-748 @JoinColumn overrides scale and percision in ManyToOne map..
Modified: annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/Ejb3JoinColumn.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/Ejb3JoinColumn.java 2009-11-05 04:28:31 UTC (rev 17918)
+++ annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/Ejb3JoinColumn.java 2009-11-05 05:21:01 UTC (rev 17919)
@@ -36,7 +36,7 @@
private String mappedByTableName;
private String mappedByEntityName;
- //FIXME hacky solution to get the information at proeprty ref resolution
+ //FIXME hacky solution to get the information at property ref resolution
public String getManyToManyOwnerSideEntityName() {
return manyToManyOwnerSideEntityName;
}
@@ -443,12 +443,25 @@
return PK_REFERENCE;
}
}
-
- public void overrideSqlTypeIfNecessary(org.hibernate.mapping.Column column) {
+
+ /**
+ * Called to apply column definitions from the referenced FK column to this column.
+ *
+ * @param column the referenced column.
+ */
+ public void overrideFromReferencedColumnIfNecessary(org.hibernate.mapping.Column column) {
+
+ // columnDefinition can also be specified using @JoinColumn, hence we have to check
+ // whether it is set or not
if ( StringHelper.isEmpty( sqlType ) ) {
sqlType = column.getSqlType();
if ( getMappingColumn() != null ) getMappingColumn().setSqlType( sqlType );
}
+
+ // these properties can only be applied on the referenced column - we can just take them over
+ getMappingColumn().setLength(column.getLength());
+ getMappingColumn().setPrecision(column.getPrecision());
+ getMappingColumn().setScale(column.getScale());
}
@Override
Modified: annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations/TableBinder.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations/TableBinder.java 2009-11-05 04:28:31 UTC (rev 17918)
+++ annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations/TableBinder.java 2009-11-05 05:21:01 UTC (rev 17919)
@@ -32,6 +32,7 @@
*
* @author Emmanuel Bernard
*/
+ at SuppressWarnings("unchecked")
public class TableBinder {
//TODO move it to a getter/setter strategy
private static Log log = LogFactory.getLog( TableBinder.class );
@@ -205,7 +206,8 @@
}
while ( mappedByColumns.hasNext() ) {
Column column = (Column) mappedByColumns.next();
- columns[0].overrideSqlTypeIfNecessary( column );
+ //columns[0].overrideSqlTypeIfNecessary( column );
+ columns[0].overrideFromReferencedColumnIfNecessary( column );
columns[0].linkValueUsingAColumnCopy( column, value );
}
}
@@ -223,7 +225,7 @@
}
while ( idColumns.hasNext() ) {
Column column = (Column) idColumns.next();
- columns[0].overrideSqlTypeIfNecessary( column );
+ columns[0].overrideFromReferencedColumnIfNecessary( column );
columns[0].linkValueUsingDefaultColumnNaming( column, referencedEntity, value );
}
}
@@ -310,7 +312,7 @@
else {
joinCol.linkWithValue( value );
}
- joinCol.overrideSqlTypeIfNecessary( col );
+ joinCol.overrideFromReferencedColumnIfNecessary( col );
match = true;
break;
}
@@ -342,8 +344,9 @@
}
else {
joinCol.linkWithValue( value );
+ joinCol.overrideFromReferencedColumnIfNecessary( synthCol );
}
- joinCol.overrideSqlTypeIfNecessary( synthCol );
+
}
}
More information about the hibernate-commits
mailing list