Greg, the problem for me is exactly how to build. I wanted to avoid buildig them by hand (ie: get the values of all the field and combining them into a java String or StringBuffer). But thank you anyway for the suggestion: if I end up for manually building statements , now I have a good location where to place my mehtods. Even though also peer classes can be used for that, couldn't be?
Il 19/01/2012 19:19, Greg Monroe ha scritto: > Or, if the info you're exporting maps to your Torque app's > tables, you could probably just add "toSQL()" methods to > the record stubs that creates the INSERT statements. > > E.g. if you have a User record object, modify the User.java > Torque created with something like: > > Public String toSQL() { > StringBuffer sql = new StringBuffer; > > // Build SQL statement from current object contents > > return sql.toString(); > } > > Then just do a normal Torque query to get the data you're > interested in and loop thru the results calling toSQL to > create your output file. > > Note that once the "stub" classes are built, Torque will not > replace them if your regenerate the code. So the toSQL() code > is safe. > > It would also be possible to create some generic Torque record to > SQL code by using the "map" information. This lets you determine > the column info in a table. So you could look up the table info > for a record object, then create the sql by iterating over the > column names and using the column type to determine the string > format to use. > > But for a few table objects, it might be easier to just do the > manually created toSQL() methods. > > -----Original Message----- > From: Thomas Vandahl [mailto:t...@apache.org] > Sent: Thursday, January 19, 2012 12:51 PM > To: Apache Torque Users List > Subject: Re: get the SQL to be executed > > On 19.01.12 18:38, Ivano Luberti wrote: >> Thanks all for your responses. >> Just to clarify, I need to generate sql commands inside my code to >> generate a file that can be used by another software (not written by me) >> to import data. >> >> I would like not to execute commands but only write them (because this >> is what I need). >> If I cannot find alternatives, I can execute them and use one of the >> logging facilities that have been suggested. > Well, inserts are sort of tricky because the actual SQL generation > happens deep inside Village. If you have control over your class loader, > you may modify a copy of the com.workingdogs.village.Record class and > put that first in the chain. Look for the saveWithInsert() method. This > is probably the closest you can get, IMHO. > > Bye, Thomas. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org > For additional commands, e-mail: torque-user-h...@db.apache.org > > DukeCE 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-unsubscr...@db.apache.org > For additional commands, e-mail: torque-user-h...@db.apache.org > > -- ================================================== dott. Ivano Mario Luberti Archimede Informatica societa' cooperativa a r. l. Sede Operativa Via Gereschi 36 - 56126- Pisa tel.: +39-050- 580959 tel/fax: +39-050-9711344 web: www.archicoop.it ================================================== --------------------------------------------------------------------- To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org