db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Monroe <Greg.Mon...@dukece.com>
Subject RE: Connection parameter
Date Mon, 09 Nov 2009 16:16:08 GMT
Not exactly sure what you are trying to do here.. but in general, the
Base classes are simply data containers.  The Peer classes are the
ones that fill the Base classes.  These have methods that take will
take a connection object.  The one exception to this is the Base save
method which can take a connection E.g., using some java5 style code...

Connection conn = Torque.getConnection("dbConnectionName");
Criteria c = new Criteria();
c.add(MyTablePeer.ColA, 1);
List<MyTable> results = doSelect(c, conn);

That said, if you're trying to add a "load" type function to the base
class.  You can do this by using code like that above and then
populating the object from the results.

FWIW, I tend to consider stuff like this part of the business logic
and make a quick wrapper class in a different package.  E.g. an
internal MyTable property that is used with get and set methods. This
will have different "load" or constructors to populate it.  The 
advantage to this is that if your business logic or DB structure 
changes so that the Foo object now need to be a combo of info from
different tables, it's easy to modify this object and all other code 
still works.

> -----Original Message-----
> From: David Urbansky [mailto:davidurbansky@googlemail.com]
> Sent: Monday, November 09, 2009 10:25 AM
> To: torque-user@db.apache.org
> Subject: Connection parameter
> Hello,
> I am using torque-gen 3.3 to generate the java model for the database
> (ant
> -f build-torque.xml). I know that it is possible to generate methods for
> the
> Base classes that also allow a connection parameter but I can not find
> the
> setting for that. So what I want is this:
> public void getABC(String t) {
>      ...
> }
> AND also
> public void getABC(String t, Connection conn) {
> ...
> }
> After generating the model I only have the first method without the
> connection parameter, does anybody know what I have to do to get the
> second
> method with the conneciton parameter too?
> Thank you very much,
>           David
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-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org

View raw message