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

         Key: HIB-157
         URL: http://jira.andromda.org/browse/HIB-157
     Project: Hibernate Cartridge
        Type: Improvement
    Versions: 3.1    
    Reporter: Jason Dillon
 Assigned to: Carlos Cuenca 
    Priority: Critical


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.




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click

Reply via email to