Author: max.andersen(a)jboss.com
Date: 2006-11-07 08:44:36 -0500 (Tue, 07 Nov 2006)
New Revision: 10748
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java
Log:
HBX-810 Remove redundant generation of @Column default values in annotation codegen
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java
===================================================================
---
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java 2006-11-07
10:57:40 UTC (rev 10747)
+++
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java 2006-11-07
13:44:36 UTC (rev 10748)
@@ -411,19 +411,30 @@
}
else {
Column column = (Column) selectable;
- annotations.append( "@" + importType("javax.persistence.Column") +
"(name=\"" ).append( column.getName() ).append( "\"" )
- .append( ", unique=" ).append( column.isUnique() )
- .append( ", nullable=" ).append( column.isNullable() )
- .append( ", insertable=" ).append( insertable )
- .append( ", updatable=" ).append( updatable );
+ annotations.append( "@" + importType("javax.persistence.Column") +
"(name=\"" ).append( column.getName() ).append( "\"" );
+ if(column.isUnique()) {
+ annotations.append( ", unique=" ).append( column.isUnique() );
+ }
+ if(!column.isNullable()) {
+ annotations.append( ", nullable=" ).append( column.isNullable() );
+ }
+
+ if(!insertable) {
+ annotations.append( ", insertable=" ).append( insertable );
+ }
+
+ if(!updatable) {
+ annotations.append( ", updatable=" ).append( updatable );
+ }
+
if (column.getPrecision() != Column.DEFAULT_PRECISION) {
annotations.append( ", precision=" ).append( column.getPrecision() );
}
- if (column.getScale() != Column.DEFAULT_SCALE) {
+ if (column.getScale() != Column.DEFAULT_SCALE) { // default is actually 0 in spec
annotations.append( ", scale=" ).append( column.getScale() );
}
- else if (column.getLength() != Column.DEFAULT_LENGTH){
+ else if (column.getLength() != Column.DEFAULT_LENGTH){ // the default is actually 0 in
spec
annotations.append( ", length=" ).append( column.getLength() );
}
Show replies by date