Specify length attribute instead of sql-type by default (make sql-type optional)

Description

This relates to this topic: http://galaxy.andromda.org/forum/viewtopic.php?p=8091


Why does setting @andromda.persistence.column.length result in a hibernate mapping generating a sql-type attribute on property elements, instead of setting a length attribute?

I'd like to use the generated Hibernate mappings for Oracle and Hypersonic, but since AndroMDA is adding sql-type overrides, I can't.

Why not use the more abstract length attribute and let Hibernate figure out what the actual type is at runtime?

For our legacy app we have a mapping that contains a property:
Code:
<property name="name" column="BNK_NAME" type="java.lang.String" length="40"/>

The AndroMDA generated version is:

Code:
<property name="name" type="java.lang.String">
<column name="BNK_NAME" not-null="false" unique="false" sql-type="VARCHAR2(40)"/>
</property>

The first should work fine w/Oracle and HSQL, the second however will only work with Oracle as HSQL does not have a VARCHAR2.

http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#mapping-declaration-property

Section 20.1.1. "Customizing the schema", under the "Table 20.1. Summary" states:

<snip>
length number column length
...
sql-type SQL column type overrides the default column type (attribute of <column> element only)
</snip>

FYI, it would also be nice to get a way to specify precision and scale too.


I suggest making the addition of sql-type to the mapping optional, and not the default.

If @andromda.persistence.column.length is set, then set the length attribute of column to its value.

if @andromda.hibernate.useSqlType is true (or something), then also add sql-type.

By not forcing the use of sql-type the generated mapping files will be more portable.

Environment

None

Assignee

Former user

Reporter

JasonJ

Labels

None

Components

Affects versions

Priority

Critical
Configure