db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <fisc...@seitenbau.net>
Subject null connections
Date Fri, 10 Jun 2005 07:38:47 GMT


I would like to ask for a general opinion about Connection objects which
are set to null. In methods which access the database, we have in almost
all cases two signatures: Obe signature without a Connection object and one
with a Connection object. For example, in AuthorPeer from the tutorial, we

AuthorPeer.doSelect(Criteria criteria);


AuthorPeer.doSelect(Criteria criteria, Connection con);

The method without connection implicitly gets one from the pool configured
for the AuthorPeer and calls the method with connection.

My question is now what should happen if the connection object is set to
null, e.g. if  AuthorPeer.doSelect(criteria, null) is called.
There are two ways to handle this.

1) implicitly get a connection and proceed
2) throw an error

At the moment, 1) is implemented, but some code looks like as if 2) was
intended at some time in the development.

The argument for 1) would be
- doSelect(Criteria criteria) is just a convenience method for
doSelect(Criteria criteria, null);
The argument for 2) is
- It allows more control. If I want the connection to be handled
implicitly, I would use the method without connection. If I explicitly use
the method with connection, I indicate that I want to handle the
connections myself. In this case, Torque should throw an error if my
connection handling is incorrect and not hide it by implicitly creating a
connection, which might not have the intended effect (e.g. new transaction
started, or different database accessed)

Personally, I would favour 2). What do you think ?


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

View raw message