db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Cooke <markcooke...@yahoo.co.uk>
Subject RE: javaName ignored?
Date Thu, 19 Oct 2006 08:47:43 GMT
Greg,
Thanks for the speedy and detailed response!

I never thought about creating a view, I might try
that, although others with the same problem might not
have that option (assuming I can get away with it).
It might be a good idea to put all the information
you've just given me in the official docs - anywhere
that discusses using torque with an existing database
maybe.
...and maybe change the description of the javaName
property to make clear that it only affects the
g(s)etter names, not all the generated code.

Many Thanks,
Mark.

--- Greg Monroe <Greg.Monroe@DukeCE.com> wrote:

> I see that this problem occurs in the the peer
> object's static column names.  This is not effected
> by the javaName attribute which is used in creating 
> the column getter/setter methods.
> 
> The problem is that Torque currently only support 
> non-delimited column names.  I.e., column names 
> that use the SQL92 (and up) identifier characters
> which matches the Java identifier rules.  So,
> delimited column names, like "@Description" can 
> break the compiler rules.
> 
> Unfortunately, I don't think there is a quick fix
> for
> this.  The column names are used extensively in a
> lot 
> of Templates for both Peer identifiers and as values
> 
> for strings that identify the SQL name.  If the 
> Column.getName() method was modified to "normalize" 
> the name, then the references to the actual column 
> name would be broken.
> 
> Also, there may be problems with the underlying 
> queries being generated.  Torque will not add the
> delimiters to column names which could cause some 
> jdbc Drivers and/or DB servers to not understand
> them.
> E.g. The query:
> 
> Select * from xxx where xxx.@Description = 'xxx' 
> 
> should be:
> 
> Select * from xxx where "xxx.@Description" = 'xxx'
> 
> to be valid SQL syntax.  Torque will generate the
> former.
> 
> Maybe a quick fix is to create a view with more
> standard names and use this with Torque?
> 
> If someone has a time to burn, I guess the correct
> fix would be to add a getPeerName method to the
> Column model that "normalizes" the name.  Then find
> all the applicable entries in the templates and use
> this method instead of the getName.
> 
> I think then you might be able to use delimited 
> names in the XML (e.g. <column name="\"@Desc\"" to 
> generate valid XML like:
> 
> Select * from xxx where xxx."@Description" = 'xxx'
> 
> 
> > -----Original Message-----
> > From: Mark Cooke [mailto:markcooke666@yahoo.co.uk]
> 
> > Sent: Wednesday, October 18, 2006 12:49 PM
> > To: torque-user@db.apache.org
> > Subject: javaName ignored?
> > 
> > Hi,
> > Context info:
> > Existing SQL Server, with three databases/schemas,
> all with 
> > the same structure...
> > I want to use torque to generate object model
> classes for 
> > some, but not all tables...
> > ...so I start by running the jdbc task (under Ant)
> against 
> > one of the dbs to get the schema xml, all fine
> > - works as docs say it should.  So then I strip
> out the 
> > tables I don't want code generating for...then run
> the "om" task.
> > Problem: Since some columns have '@' at the start
> of names 
> > (@description, for instance), so does the code
> which refers 
> > to these columns. The docs say "javaName"
> > attribute can be used to specify what the column
> is called in 
> > java, so that's what I did - except it doesn't
> make the 
> > blindest bit of difference.
> > So, What am I doing wrong?  Have I missed some
> config somewhere?
> > 
> > Thanks in Advance,
> > Mark.
> > 
> > Send instant messages to your online friends 
> > http://uk.messenger.yahoo.com 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail:
> torque-user-help@db.apache.org
> > 
> > 
> 
> Duke CE Privacy Statement
> Please be advised that this e-mail and any files
> transmitted with it are confidential communication
> or may otherwise be privileged or confidential and
> are intended solely for the individual or entity to
> whom they are addressed.  If you are not the
> intended recipient you may not rely on the contents
> of this email or any attachments, and we ask that
> you  please not read, copy or retransmit this
> communication, but reply to the sender and destroy
> the email, its contents, and all copies thereof
> immediately.  Any unauthorized dissemination,
> distribution or copying of this communication is
> strictly prohibited.
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail:
> torque-user-help@db.apache.org
> 
> 


Send instant messages to your online friends http://uk.messenger.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message