Johan- I had to write an Abstract DAO that all my TorqueDAOs extend.
This abstract DAO provides the following functionality for getting and releasing connections. ---------------- import org.springframework.jdbc.CannotGetJdbcConnectionException; import org.springframework.jdbc.datasource.DataSourceUtils; /** * Gets a connection * * @return Connection */ protected Connection getConnection() { try { DataSource dataSource = (DataSource) Registry .get("dataSource"); Connection conn = DataSourceUtils.getConnection(dataSource); logger.debug("Got connection from pool"); return conn; } catch (CannotGetJdbcConnectionException e) { throw new SystemException(e); } } /** * Releases a connection * * @return Connection */ protected void releaseConnection(Connection conn) { try { DataSource dataSource = (DataSource) Registry .get("dataSource"); DataSourceUtils.closeConnectionIfNecessary(conn, dataSource); logger.debug("Releasing connection back to pool"); } catch (CannotGetJdbcConnectionException e) { throw new SystemException(e); } } ----- You can then use the connection to call methods on your Peer classes in order for Torque to participate in Spring-managed transactions. This abstract DAO will also be responsible for handling Torque exceptions via template methods for your CRUD operations. For example, -------- protected final Collection find(Criteria criteria) { Connection conn = null; Collection results = null; try { conn = getConnection(); results = basicFind(criteria, conn); } finally { releaseConnection(conn); } return results; } /** * Generic method for selecting table data based on freeform criteria * * @param criteria * Criteria * @param conn * Connection * @return Collection of appropriate domain object items */ public abstract Collection basicFind(Criteria criteria, Connection conn); ----------- As you can see, all my queries are Criteria driven and the actual implementation is provided for in my derived class. Michael -----Original Message----- From: Johan Andries [mailto:[EMAIL PROTECTED] Sent: Monday, January 31, 2005 11:17 AM To: Apache Torque Users List Subject: Re: [BULK] torque and spring Hi Michael, specifically I'm looking whether it's possible to let the generated data access classes participate in transactions, i.e. to have datasources which take part in a transactioned context. Besides that, I was wondering whether it's possible to configure the classes dynamically with new datasources, and last but not least, do they have a flexible try/catch/finally solution (which was - face it - quite terrible when using plain old JDBC). But mainly I don't know about this because I didn't have a lot of time yet to look at the generated classes. That's why I posted on the list whether someone has already successfully integrated these classes into Spring or not. Because we really need to make a fast decision ATM - to decide between our own proprietary framework, Torque or maybe something else. cheers, Johan [EMAIL PROTECTED] wrote: >Johan- > >What specifically are you looking for? > >Michael > >-----Original Message----- >From: Johan Andries [mailto:[EMAIL PROTECTED] >Sent: Monday, January 31, 2005 8:59 AM >To: torque-user@db.apache.org >Subject: [BULK] torque and spring > > >Hello, > >Has anyone ever done a successful attempt on integrating the generated >Torque Java classes in the Spring framework? I've searched the mailing >list archive and found no references to this. > >Kind regards, >Johan > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]