db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Quinton McCombs" <qmcco...@nequalsone.com>
Subject RE: AW: Copy criteria object
Date Thu, 13 Feb 2003 17:29:16 GMT
No need to do this.  The database tag in your project-schema.xml file allows for this already.

<database basePeer="com.mycompany.om.CustomBasePeer"
          baseClass="com.mycompany.om.CustomBaseClass">



> -----Original Message-----
> From: Campbell, Justin [mailto:jcampbell@profilesys.com] 
> Sent: Thursday, February 13, 2003 11:10 AM
> To: 'Turbine Torque Users List'
> Subject: RE: AW: Copy criteria object
> 
> 
> Marc -
> 
> Allow me to prefix this message with a disclaimer: I don't 
> really recommend modifying things at this level. Now, on to 
> how to actually do it :)
> 
> You can modify the velocity templates that Torque uses to 
> generate your Java source. They're found in 
> "src/templates/om" beneath your root Torque-install 
> directory. For Torque 3.0.0, on line 54-55 you'll see 
> something like this:
> 
> public abstract class $basePrefix${table.JavaName}Peer
>     extends $table.BasePeer
> 
> You can then change the "extends" statement to be whatever 
> you like. Be sure to change the import statements earlier in 
> the template to include whatever class it is you've created, as well.
> 
> Hope this helps and best of luck.
> 
> Justin Campbell
> Project Technical Lead
> Profile Systems, Inc.
> 
> -----Original Message-----
> From: Marc Lustig [mailto:mail@marclustig.com]
> Sent: Thursday, February 13, 2003 12:05 PM
> To: Turbine Torque Users List
> Subject: AW: AW: Copy criteria object
> 
> 
> Jürgen,
> do I understand you correct, you extended Torque's BasePeer 
> class and added custom functionality? This is something that 
> I also wanted to do, not only for BasePeer, but also for 
> BaseObject. But I wonder how do you tell Torque to use your 
> Peer class when generating the Peers, instead of BasePeer? I 
> can't find a property in 
> http://jakarta.apache.org/turbine/torque-3.0.0/properties-refe
> rence.html
> 
> I'm curious to know ...
> 
> 
> 
> 
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Jürgen Hoffmann [mailto:jh@byteaction.de]
> > Gesendet: Donnerstag, 13. Februar 2003 15:44
> > An: 'Turbine Torque Users List'
> > Betreff: AW: AW: Copy criteria object
> >
> >
> > Hi,
> >
> > Thanx a lot for cheering me up this morning, but I actually found a 
> > solution for the problem.
> >
> > This is how (my Extended BasePeer):
> > 	public static long getNumberOfRowsInTable(String table, Criteria
> > c) throws TorqueException, DataSetException
> > 	{
> > 		c.addSelectColumn("COUNT(*)");
> > 		String query = createQueryString(c);
> > 		Log.debug("Query: " + query);
> > 		c.getSelectColumns().clear();
> > 		Log.debug("Query with original Criteria: " + 
> createQueryString(c));
> > 		return
> > ((Record)executeQuery(query).get(0)).getValue(1).asLong();
> > 	}
> >
> > I bet you see where the trick is ;)
> > (All the logs were just for debugging purposes)
> >
> > P.S. Anyone interested in a lazy_paging macro for 
> Globalmacros? And a 
> > Patch for BasePeer to support this homegrown?
> >
> > Kind regards
> >
> > Jürgen Hoffmann
> > ByteACTION GmbH
> >
> > cert. Perl Programmer
> > cert. Linux System Administrator
> > cert. Java Programmer
> >
> > Besuchen Sie uns doch auf der CeBIT 2003
> > in Halle 4/Stand 70
> >
> >
> > -----Ursprüngliche Nachricht-----
> > Von: peter riegersperger [mailto:rick@subnet.at]
> > Gesendet: Donnerstag, 13. Februar 2003 11:40
> > An: Turbine Torque Users List
> > Betreff: Re: AW: Copy criteria object
> >
> >
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > [...]
> > > > Which is correct. Then I want to use a "copy" of the criteria 
> > > > object
> >
> > > > and modify it like this: myCrit = cri.clone(); 
> > > > myCrit.addSelectColumn("COUNT(*)");
> > > > Log.debug(WebserverDailyPeer.createQueryString(cri));
> > > >
> > > > But then I get:
> > > > SELECT COUNT(*) FROM webserver_daily WHERE
> > > > 
> webserver_daily.DAY='(UNIX_TIMESTAMP(webserver_daily.DAY) between 
> > > > 1009839600 and 1041375600 )' AND webserver_daily.KID=3
> >
> > apparently, Criteria does not implement clone().
> > if it cheers you up, you're not alone: 
> > 
> http://www.mail-archive.com/turbine-torque-user@jakarta.apache.org/msg
> > 01
> > 480.html
> >
> > (probably you find something useful for you in this thread)
> >
> > i ended up working around this problem by creating a specific query 
> > for Counts, either with Criteria (it should work if you 
> just use the 
> > Criteria one time), or with the village objects themself.
> >
> > rick
> >
> >
> > - --
> > |-
> > | peter riegersperger  <rick@subnet.at>
> > |-
> > | ein windows switcher tagebuch: 
> > |http://forum.subnet.at/viewforum.php?f=22
> > |-
> > | subnet
> > | platform for media art and experimental technologies
> > |-
> > | http://www.subnet.at/
> > |-
> > | muehlbacherhofweg 5 // 5020 salzburg // austria
> > |-
> > | fon/fax +43/662/842 897
> > |-
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.0.7 (GNU/Linux)
> >
> > iD8DBQE+S3X4IMP39JYOy9IRAh6YAKDYqPN9i23ZLVRWMi2WjJ93JQDfMgCfT9Ea
> > sj1QPXpekJEMzf2anbyMO9U=
> > =YFuR
> > -----END PGP SIGNATURE-----
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> >
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> ---------------------------------------------------------------------
> 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