Author: max.andersen(a)jboss.com
Date: 2006-11-08 06:58:22 -0500 (Wed, 08 Nov 2006)
New Revision: 10768
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/EntityPOJOClass.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-08
06:55:52 UTC (rev 10767)
+++
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java 2006-11-08
11:58:22 UTC (rev 10768)
@@ -413,21 +413,8 @@
Column column = (Column) selectable;
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() );
- }
+ appendCommonColumnInfo( annotations, column, insertable, updatable );
- 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() );
}
@@ -440,16 +427,36 @@
- String sqlType = column.getSqlType();
- if ( StringHelper.isNotEmpty( sqlType ) ) {
- annotations.append( ", columnDefinition=\"" ).append( sqlType
).append( "\"" );
- }
+
//TODO support secondary table
annotations.append( ")" );
}
}
+ protected void appendCommonColumnInfo(StringBuffer annotations, Column column, boolean
insertable, boolean updatable) {
+ 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 );
+ }
+
+ String sqlType = column.getSqlType();
+ if ( StringHelper.isNotEmpty( sqlType ) ) {
+ annotations.append( ", columnDefinition=\"" ).append( sqlType ).append(
"\"" );
+ }
+
+ }
+
public Iterator getToStringPropertiesIterator() {
Iterator iter = getAllPropertiesIterator();
return getToStringPropertiesIterator( iter );
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java
===================================================================
---
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java 2006-11-08
06:55:52 UTC (rev 10767)
+++
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/pojo/EntityPOJOClass.java 2006-11-08
11:58:22 UTC (rev 10768)
@@ -376,17 +376,10 @@
else {
Column column = (Column) selectable;
annotations.append("(a)").append(
importType("javax.persistence.JoinColumn") )
- .append("(name=\"" ).append( column.getName() ).append(
"\"" )
+ .append("(name=\"" ).append( column.getName() ).append(
"\"" );
//TODO handle referenced column name, this is a hard one
//.append(", referencedColumnName=")
- .append( ", unique=" ).append( column.isUnique() )
- .append( ", nullable=" ).append( column.isNullable() )
- .append( ", insertable=" ).append( insertable )
- .append( ", updatable=" ).append( updatable );
- String sqlType = column.getSqlType();
- if ( StringHelper.isNotEmpty( sqlType ) ) {
- annotations.append( ", columnDefinition=\"" ).append( sqlType
).append( "\"" );
- }
+ appendCommonColumnInfo(annotations, column, insertable, updatable);
//TODO support secondary table
annotations.append( ")" );
}
Show replies by date