>
> >
> > * Should we hear the comments from that guy about Informix, and
> > use TB, TRB or TRBN as a prefix (object name lengths) instead
> > of TURBINE?
>
> How about the following:
> Torque could be changed to shorten the names of db-objects to
> a specified
> length.
Also there was no reaction on this following this explanation is a
patch,which opens the possibility to get a shortened name for the database
objects. The process is controlled by an optional parameter '
maximumLength="18"' for the targets 'project-om' and 'project-sql' in
torque.xml.
The classes used in the generation process, expose a new property
"mangledName", which contains a shortened name. Using this property in the
templates will not change the generated code, if the property is not set in
the ant-target, or is set to a larger value as the longest table name (btw
it defaults to 32).
To get it completely working the templates have to be changed accordingly.
For the sql-templates this is no problem, because they are kept in distinct
directories for each db-system, so in this part, it could be done only for
informix. But it has also be done for the peer generation.
Stefan Günther
Index: turbine/src/java/org/apache/turbine/torque/ant/VTorqueTask.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/torque/ant/VTorque
Task.java,v
retrieving revision 1.2
diff -r1.2 VTorqueTask.java
81a82,85
> /** the maximum allowed lenght of db-objects
> */
> private int dbNamelength=32;
>
86a91,107
> * Get the allowed namelenght for db objects
> */
> public String getMaximumLength()
> {
> return String.valueOf(dbNamelength);
> }
>
> /**
> * Set the allowed namelenght for db objects
> */
> public void setMaximumLength(String len)
> {
> Integer i= new Integer(len);
> dbNamelength = i.intValue();
> }
>
> /**
141a163
> app.setMaximumLength(dbNamelength);
Index: turbine/src/java/org/apache/turbine/torque/model/AppData.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/torque/model/AppDa
ta.java,v
retrieving revision 1.1
diff -r1.1 AppData.java
74a75
> private int dbNamelength;
82a84,99
> }
>
> /**
> * Get the allowed namelenght for db objects
> */
> public int getMaximumLength()
> {
> return dbNamelength;
> }
>
> /**
> * Set the allowed namelenght for db objects
> */
> public void setMaximumLength(int len)
> {
> dbNamelength = len;
Index: turbine/src/java/org/apache/turbine/torque/model/Column.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/torque/model/Colum
n.java,v
retrieving revision 1.2
diff -r1.2 Column.java
199c199
< return parentTable.getName()+"."+name;
---
> return parentTable.getMangledName()+"."+name;
268a269,277
> /**
> * Returns the Name of the table the column is in
> */
> public String getMangledTableName()
> {
> return parentTable.getMangledName();
> }
>
>
Index: turbine/src/java/org/apache/turbine/torque/model/Index.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/torque/model/Index
.java,v
retrieving revision 1.3
diff -r1.3 Index.java
123a124,136
> * Get the name of the index, taking maximum namelength into account
> */
> public String getMangledIndexName()
> {
> int len=indexName.length();
> if(len<parentTable.getMaximumLength())
> {
> return indexName;
> }
> return indexName.substring(0,parentTable.getMaximumLength());
> }
>
> /**
Index: turbine/src/java/org/apache/turbine/torque/model/Table.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/torque/model/Table
.java,v
retrieving revision 1.1
diff -r1.1 Table.java
87a88,89
>
>
119c121,128
<
---
> /**
> * Get the allowed namelenght for db objects
> */
> public int getMaximumLength()
> {
> return tableParent.getMaximumLength();
> }
>
227a237,250
> /**
> * Get the name of the table, taking maximum namelength into account
> */
> public String getMangledName()
> {
>
> int len=name.length();
> if(len <= tableParent.getMaximumLength())
> {
> return name;
> }
> return name.substring(0,tableParent.getMaximumLength());
> }
>
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]