You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by stewart titan <st...@yahoo.co.uk> on 2002/01/23 14:37:46 UTC

Help with Torque

 Hi

(Apoloygise for the repost, but I forgot to change the
subject heading on my previous post)
 
 Are there an small example applications etc of how
 to
 use Torque?  I'm able to generate the classes and
 sql,
 but how to use the classes - the peer classes and
 "non
 peer" classes, ie, 
 
 There are two classes in which to put your own code
 in:
 project
 ProjectPeer
 
 How do you use these? Ie, the code inside these
 actually classes, the difference between the two,
 and
 how to use these classes in an application.  
 
 I've read the docs, but still, no help, using the
 criteria etc is fine, but there are missing examples
 that I need to get going. So a sample application
 would answer my questions.
 
 Help is very much appreciated.
 
 Thank You
 


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Help with Torque

Posted by Fabian Moerchen <fa...@mybytes.de>.
hi

i'm another one that's still learning...some things i want to comment: 

> I am new to this as well, but I have not had to modify any *Peer objects. I
> get the feeling that you could add methods to this file if you are sure they
> are not db dependent.

the Peers Howto talks about this, you could add convenience methods like
findAll, findByName, etc.

> Most effort will be in the Address class (in our example). When you look at
> this class as generated by Torque, it simply extends BaseAddress adding no
> methods of its own. 

this is perfect for business logic. e.g. override some set* methods to
prevent certain values. 

> I used this in my case to create selects from other
> tables to fetch field-values for this insert (does that make sense?).

no, what do you mean exactly?

for 1:n or m:n relationships the generated Base* classes already provide
convenience methods.

bye
fabian

On Wed, 2002-01-23 at 18:35, sbelt wrote:
> Let me start by saying that I am new to Torque as well. But I did get an
> application running (thanks in a large help to users on this list). Here
> would be my high-level view of how to use the classes. If anyone disagrees
> with me - believe THEM ;)
> 
> Most of this is information I dug out of the site or the Mail Archives which
> was most useful to me.
> 
> Suppose your schema.xml defined a table called Address (I'll leave it to
> your imagination to guess what fields would be in a table with this name;).
> You will find that Torque created files BaseAddressPeer, AddressPeer,
> BaseAddress, and Address.
> 
> In your class constructor, add code which initializes torque if it is not
> already running. I used the following:
> // setup torque for database access and pooling
> try
> {
>    if ( !Torque.isInit() )
>    {
>         Torque.init("ndb.properties");
>         System.out.println( "[MyClass.constructor()] Torque.init completed
> successfully\n");
>     }
>     else
>     {
>         System.out.println( "[MyClass.constructor()] Torque.init is already
> running\n");
>     }
> }
> catch( Exception e )
> {
>     System.out.println( "[MyClass.constructor()] error running
> Torque.init:\n" + e );
> }
> 
> Now all you need to do is instantiate the Address class, create criterias,
> and parse results. (This is off the top of my head, so consider it
> pseudo-code at best):
> 
> Address address = new Address();// you now have a hook into all that Torque
> functionality
> Criteria criteria = new Criteria();
> criteria.add(AddressPeer.LastName, "Jones");//LastName was a field defined
> in schema.xml
> Vector v = AddressPeer.doSelect( criteria ); // v contains a vector of
> address objects
> for (int x = 0; x<v.size; v++){
>     String firstName = ((Address)v.get(x)).getFirstName(); //FirstName is a
> field defined by schema.xml
>     String lastName = ((Address)v.get(x)).getLastName(); //LastName is a
> field defined by schema.xml
>     System.out.println(lastName +", "+ firstName);
> }
> 
> If you need to start modifying the Torque code, here are some pointers:
> 
> The Base* files you should never have to change. They are generated each
> time you run torque, and may change if, for example, you change databases.
> BTW, the when you re-run torque, unless you deleted them, the non-Base*
> files are not overwritten.
> 
> I am new to this as well, but I have not had to modify any *Peer objects. I
> get the feeling that you could add methods to this file if you are sure they
> are not db dependent.
> 
> Most effort will be in the Address class (in our example). When you look at
> this class as generated by Torque, it simply extends BaseAddress adding no
> methods of its own. I used this in my case to create selects from other
> tables to fetch field-values for this insert (does that make sense?). If I
> re-run Torqe for a new database - because only the Base* classes are
> replaced - my code should continue to function!
> 
> I HTH. As I said, I am still learning myself. My experience so far has only
> been in using the Torque-generated stuff, so I know nothing of how Torque
> itself works.  If you have any questions, I'll do my best to share any
> experince I might have in common.
> 
> Steve B.
> ----- Original Message -----
> From: "stewart titan" <st...@yahoo.co.uk>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Wednesday, January 23, 2002 5:37 AM
> Subject: Help with Torque
> 
> 
> >
> >  Hi
> >
> > (Apoloygise for the repost, but I forgot to change the
> > subject heading on my previous post)
> >
> >  Are there an small example applications etc of how
> >  to
> >  use Torque?  I'm able to generate the classes and
> >  sql,
> >  but how to use the classes - the peer classes and
> >  "non
> >  peer" classes, ie,
> >
> >  There are two classes in which to put your own code
> >  in:
> >  project
> >  ProjectPeer
> >
> >  How do you use these? Ie, the code inside these
> >  actually classes, the difference between the two,
> >  and
> >  how to use these classes in an application.
> >
> >  I've read the docs, but still, no help, using the
> >  criteria etc is fine, but there are missing examples
> >  that I need to get going. So a sample application
> >  would answer my questions.
> >
> >  Help is very much appreciated.
> >
> >  Thank You
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Everything you'll ever need on one web page
> > from News and Sport to Email and Music Charts
> > http://uk.my.yahoo.com
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Help with Torque

Posted by Emmanuel Bardet <em...@bardet.org>.
You're doing really well, Pete. Keep on the good job!

> -----Original Message-----
> From: Pete Kazmier [mailto:pete@kazmier.com]
> Sent: mercredi 23 janvier 2002 20:36
> To: Turbine Users List
> Subject: Re: Help with Torque
>
>
> I'm about to complete a Torque tutorial (its an xdoc).  It should be
> complete in a few days (hopefully tonight), then I'll post it to the
> list for comments.  In the meantime, if anyone is interested, the draft
> can be found at:
>
> http://www.kazmier.com/~kaz/torque/tutorial.html
>
> Thanks,
> Pete
>
> On Wed, Jan 23, 2002 at 08:10:35PM +0100, Martin Poeschl wrote:
> > would be nice if you could add your infoemation to the xdocs
> and send a patch ;-)
> >
> > also take a look at the testbed. it
> >
> > - generates the sql
> > - creates the db and tables
> > - creates the om/peer classes
> > - inserts some data to the db
> > - grabs the data from the db and generates data.xml and data.sql files
> >
> > you are right there should be better docs ... patches are very
> welcome ;-)
> >
> > martin
> >
> >
> > sbelt wrote:
> > > Let me start by saying that I am new to Torque as well. But I
> did get an
> > > application running (thanks in a large help to users on this
> list). Here
> > > would be my high-level view of how to use the classes. If
> anyone disagrees
> > > with me - believe THEM ;)
> > >
> > > Most of this is information I dug out of the site or the Mail
> Archives which
> > > was most useful to me.
> > >
> > > Suppose your schema.xml defined a table called Address (I'll
> leave it to
> > > your imagination to guess what fields would be in a table
> with this name;).
> > > You will find that Torque created files BaseAddressPeer, AddressPeer,
> > > BaseAddress, and Address.
> > >
> > > In your class constructor, add code which initializes torque
> if it is not
> > > already running. I used the following:
> > > // setup torque for database access and pooling
> > > try
> > > {
> > >    if ( !Torque.isInit() )
> > >    {
> > >         Torque.init("ndb.properties");
> > >         System.out.println( "[MyClass.constructor()]
> Torque.init completed
> > > successfully\n");
> > >     }
> > >     else
> > >     {
> > >         System.out.println( "[MyClass.constructor()]
> Torque.init is already
> > > running\n");
> > >     }
> > > }
> > > catch( Exception e )
> > > {
> > >     System.out.println( "[MyClass.constructor()] error running
> > > Torque.init:\n" + e );
> > > }
> > >
> > > Now all you need to do is instantiate the Address class,
> create criterias,
> > > and parse results. (This is off the top of my head, so consider it
> > > pseudo-code at best):
> > >
> > > Address address = new Address();// you now have a hook into
> all that Torque
> > > functionality
> > > Criteria criteria = new Criteria();
> > > criteria.add(AddressPeer.LastName, "Jones");//LastName was a
> field defined
> > > in schema.xml
> > > Vector v = AddressPeer.doSelect( criteria ); // v contains a vector of
> > > address objects
> > > for (int x = 0; x<v.size; v++){
> > >     String firstName = ((Address)v.get(x)).getFirstName();
> //FirstName is a
> > > field defined by schema.xml
> > >     String lastName = ((Address)v.get(x)).getLastName();
> //LastName is a
> > > field defined by schema.xml
> > >     System.out.println(lastName +", "+ firstName);
> > > }
> > >
> > > If you need to start modifying the Torque code, here are some
> pointers:
> > >
> > > The Base* files you should never have to change. They are
> generated each
> > > time you run torque, and may change if, for example, you
> change databases.
> > > BTW, the when you re-run torque, unless you deleted them, the
> non-Base*
> > > files are not overwritten.
> > >
> > > I am new to this as well, but I have not had to modify any
> *Peer objects. I
> > > get the feeling that you could add methods to this file if
> you are sure they
> > > are not db dependent.
> > >
> > > Most effort will be in the Address class (in our example).
> When you look at
> > > this class as generated by Torque, it simply extends
> BaseAddress adding no
> > > methods of its own. I used this in my case to create selects
> from other
> > > tables to fetch field-values for this insert (does that make
> sense?). If I
> > > re-run Torqe for a new database - because only the Base* classes are
> > > replaced - my code should continue to function!
> > >
> > > I HTH. As I said, I am still learning myself. My experience
> so far has only
> > > been in using the Torque-generated stuff, so I know nothing
> of how Torque
> > > itself works.  If you have any questions, I'll do my best to share any
> > > experince I might have in common.
> > >
> > > Steve B.
> > > ----- Original Message -----
> > > From: "stewart titan" <st...@yahoo.co.uk>
> > > To: "Turbine Users List" <tu...@jakarta.apache.org>
> > > Sent: Wednesday, January 23, 2002 5:37 AM
> > > Subject: Help with Torque
> > >
> > >
> > >
> > >> Hi
> > >>
> > >>(Apoloygise for the repost, but I forgot to change the
> > >>subject heading on my previous post)
> > >>
> > >> Are there an small example applications etc of how
> > >> to
> > >> use Torque?  I'm able to generate the classes and
> > >> sql,
> > >> but how to use the classes - the peer classes and
> > >> "non
> > >> peer" classes, ie,
> > >>
> > >> There are two classes in which to put your own code
> > >> in:
> > >> project
> > >> ProjectPeer
> > >>
> > >> How do you use these? Ie, the code inside these
> > >> actually classes, the difference between the two,
> > >> and
> > >> how to use these classes in an application.
> > >>
> > >> I've read the docs, but still, no help, using the
> > >> criteria etc is fine, but there are missing examples
> > >> that I need to get going. So a sample application
> > >> would answer my questions.
> > >>
> > >> Help is very much appreciated.
> > >>
> > >> Thank You
> > >>
> > >>
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>

--
Peter Kazmier                                 http://www.kazmier.com
PGP Fingerprint   4FE7 8DA3 D0B5 9CAA 69DC  7243 1855 BC2E 4B43 5654

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Help with Torque

Posted by Pete Kazmier <pe...@kazmier.com>.
I'm about to complete a Torque tutorial (its an xdoc).  It should be
complete in a few days (hopefully tonight), then I'll post it to the
list for comments.  In the meantime, if anyone is interested, the draft
can be found at:

http://www.kazmier.com/~kaz/torque/tutorial.html

Thanks,
Pete

On Wed, Jan 23, 2002 at 08:10:35PM +0100, Martin Poeschl wrote:
> would be nice if you could add your infoemation to the xdocs and send a patch ;-)
> 
> also take a look at the testbed. it
> 
> - generates the sql
> - creates the db and tables
> - creates the om/peer classes
> - inserts some data to the db
> - grabs the data from the db and generates data.xml and data.sql files
> 
> you are right there should be better docs ... patches are very welcome ;-)
> 
> martin
> 
> 
> sbelt wrote:
> > Let me start by saying that I am new to Torque as well. But I did get an
> > application running (thanks in a large help to users on this list). Here
> > would be my high-level view of how to use the classes. If anyone disagrees
> > with me - believe THEM ;)
> > 
> > Most of this is information I dug out of the site or the Mail Archives which
> > was most useful to me.
> > 
> > Suppose your schema.xml defined a table called Address (I'll leave it to
> > your imagination to guess what fields would be in a table with this name;).
> > You will find that Torque created files BaseAddressPeer, AddressPeer,
> > BaseAddress, and Address.
> > 
> > In your class constructor, add code which initializes torque if it is not
> > already running. I used the following:
> > // setup torque for database access and pooling
> > try
> > {
> >    if ( !Torque.isInit() )
> >    {
> >         Torque.init("ndb.properties");
> >         System.out.println( "[MyClass.constructor()] Torque.init completed
> > successfully\n");
> >     }
> >     else
> >     {
> >         System.out.println( "[MyClass.constructor()] Torque.init is already
> > running\n");
> >     }
> > }
> > catch( Exception e )
> > {
> >     System.out.println( "[MyClass.constructor()] error running
> > Torque.init:\n" + e );
> > }
> > 
> > Now all you need to do is instantiate the Address class, create criterias,
> > and parse results. (This is off the top of my head, so consider it
> > pseudo-code at best):
> > 
> > Address address = new Address();// you now have a hook into all that Torque
> > functionality
> > Criteria criteria = new Criteria();
> > criteria.add(AddressPeer.LastName, "Jones");//LastName was a field defined
> > in schema.xml
> > Vector v = AddressPeer.doSelect( criteria ); // v contains a vector of
> > address objects
> > for (int x = 0; x<v.size; v++){
> >     String firstName = ((Address)v.get(x)).getFirstName(); //FirstName is a
> > field defined by schema.xml
> >     String lastName = ((Address)v.get(x)).getLastName(); //LastName is a
> > field defined by schema.xml
> >     System.out.println(lastName +", "+ firstName);
> > }
> > 
> > If you need to start modifying the Torque code, here are some pointers:
> > 
> > The Base* files you should never have to change. They are generated each
> > time you run torque, and may change if, for example, you change databases.
> > BTW, the when you re-run torque, unless you deleted them, the non-Base*
> > files are not overwritten.
> > 
> > I am new to this as well, but I have not had to modify any *Peer objects. I
> > get the feeling that you could add methods to this file if you are sure they
> > are not db dependent.
> > 
> > Most effort will be in the Address class (in our example). When you look at
> > this class as generated by Torque, it simply extends BaseAddress adding no
> > methods of its own. I used this in my case to create selects from other
> > tables to fetch field-values for this insert (does that make sense?). If I
> > re-run Torqe for a new database - because only the Base* classes are
> > replaced - my code should continue to function!
> > 
> > I HTH. As I said, I am still learning myself. My experience so far has only
> > been in using the Torque-generated stuff, so I know nothing of how Torque
> > itself works.  If you have any questions, I'll do my best to share any
> > experince I might have in common.
> > 
> > Steve B.
> > ----- Original Message -----
> > From: "stewart titan" <st...@yahoo.co.uk>
> > To: "Turbine Users List" <tu...@jakarta.apache.org>
> > Sent: Wednesday, January 23, 2002 5:37 AM
> > Subject: Help with Torque
> > 
> > 
> > 
> >> Hi
> >>
> >>(Apoloygise for the repost, but I forgot to change the
> >>subject heading on my previous post)
> >>
> >> Are there an small example applications etc of how
> >> to
> >> use Torque?  I'm able to generate the classes and
> >> sql,
> >> but how to use the classes - the peer classes and
> >> "non
> >> peer" classes, ie,
> >>
> >> There are two classes in which to put your own code
> >> in:
> >> project
> >> ProjectPeer
> >>
> >> How do you use these? Ie, the code inside these
> >> actually classes, the difference between the two,
> >> and
> >> how to use these classes in an application.
> >>
> >> I've read the docs, but still, no help, using the
> >> criteria etc is fine, but there are missing examples
> >> that I need to get going. So a sample application
> >> would answer my questions.
> >>
> >> Help is very much appreciated.
> >>
> >> Thank You
> >>
> >>
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 

-- 
Peter Kazmier                                 http://www.kazmier.com
PGP Fingerprint   4FE7 8DA3 D0B5 9CAA 69DC  7243 1855 BC2E 4B43 5654

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Help with Torque

Posted by Martin Poeschl <mp...@marmot.at>.
would be nice if you could add your infoemation to the xdocs and send a patch ;-)

also take a look at the testbed. it

- generates the sql
- creates the db and tables
- creates the om/peer classes
- inserts some data to the db
- grabs the data from the db and generates data.xml and data.sql files

you are right there should be better docs ... patches are very welcome ;-)

martin


sbelt wrote:
> Let me start by saying that I am new to Torque as well. But I did get an
> application running (thanks in a large help to users on this list). Here
> would be my high-level view of how to use the classes. If anyone disagrees
> with me - believe THEM ;)
> 
> Most of this is information I dug out of the site or the Mail Archives which
> was most useful to me.
> 
> Suppose your schema.xml defined a table called Address (I'll leave it to
> your imagination to guess what fields would be in a table with this name;).
> You will find that Torque created files BaseAddressPeer, AddressPeer,
> BaseAddress, and Address.
> 
> In your class constructor, add code which initializes torque if it is not
> already running. I used the following:
> // setup torque for database access and pooling
> try
> {
>    if ( !Torque.isInit() )
>    {
>         Torque.init("ndb.properties");
>         System.out.println( "[MyClass.constructor()] Torque.init completed
> successfully\n");
>     }
>     else
>     {
>         System.out.println( "[MyClass.constructor()] Torque.init is already
> running\n");
>     }
> }
> catch( Exception e )
> {
>     System.out.println( "[MyClass.constructor()] error running
> Torque.init:\n" + e );
> }
> 
> Now all you need to do is instantiate the Address class, create criterias,
> and parse results. (This is off the top of my head, so consider it
> pseudo-code at best):
> 
> Address address = new Address();// you now have a hook into all that Torque
> functionality
> Criteria criteria = new Criteria();
> criteria.add(AddressPeer.LastName, "Jones");//LastName was a field defined
> in schema.xml
> Vector v = AddressPeer.doSelect( criteria ); // v contains a vector of
> address objects
> for (int x = 0; x<v.size; v++){
>     String firstName = ((Address)v.get(x)).getFirstName(); //FirstName is a
> field defined by schema.xml
>     String lastName = ((Address)v.get(x)).getLastName(); //LastName is a
> field defined by schema.xml
>     System.out.println(lastName +", "+ firstName);
> }
> 
> If you need to start modifying the Torque code, here are some pointers:
> 
> The Base* files you should never have to change. They are generated each
> time you run torque, and may change if, for example, you change databases.
> BTW, the when you re-run torque, unless you deleted them, the non-Base*
> files are not overwritten.
> 
> I am new to this as well, but I have not had to modify any *Peer objects. I
> get the feeling that you could add methods to this file if you are sure they
> are not db dependent.
> 
> Most effort will be in the Address class (in our example). When you look at
> this class as generated by Torque, it simply extends BaseAddress adding no
> methods of its own. I used this in my case to create selects from other
> tables to fetch field-values for this insert (does that make sense?). If I
> re-run Torqe for a new database - because only the Base* classes are
> replaced - my code should continue to function!
> 
> I HTH. As I said, I am still learning myself. My experience so far has only
> been in using the Torque-generated stuff, so I know nothing of how Torque
> itself works.  If you have any questions, I'll do my best to share any
> experince I might have in common.
> 
> Steve B.
> ----- Original Message -----
> From: "stewart titan" <st...@yahoo.co.uk>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Wednesday, January 23, 2002 5:37 AM
> Subject: Help with Torque
> 
> 
> 
>> Hi
>>
>>(Apoloygise for the repost, but I forgot to change the
>>subject heading on my previous post)
>>
>> Are there an small example applications etc of how
>> to
>> use Torque?  I'm able to generate the classes and
>> sql,
>> but how to use the classes - the peer classes and
>> "non
>> peer" classes, ie,
>>
>> There are two classes in which to put your own code
>> in:
>> project
>> ProjectPeer
>>
>> How do you use these? Ie, the code inside these
>> actually classes, the difference between the two,
>> and
>> how to use these classes in an application.
>>
>> I've read the docs, but still, no help, using the
>> criteria etc is fine, but there are missing examples
>> that I need to get going. So a sample application
>> would answer my questions.
>>
>> Help is very much appreciated.
>>
>> Thank You
>>
>>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Torque.Iniit() - Re: Help with Torque

Posted by Pete Kazmier <pe...@kazmier.com>.
On Tue, Jan 29, 2002 at 02:13:10PM -0600, Dave Everson wrote:
> Nice documentation Pete.

Thanks!

> My question is, what changes do I need to make in the configuration of
> a Turbine 2.1 webapp to seamlessly use the OM classes generated by the
> standalone Torque.  Do you have any documentation or suggestions on
> how to perform this?

Unfortunately, I don't have any suggestions to offer because I haven't
used Turbine 2.  Perhaps someone else on this list might be able to
offer some suggestions.

Thanks,
Pete

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Torque.Iniit() - Re: Help with Torque

Posted by Dave Everson <dj...@mygolftrac.com>.
Nice documentation Pete.
I just built/setup Torque 3, primarily because to get OM for a new
standalone application we are developing with Turbine.  We have several
requirements to expose this data via a Turbine Webapp as well.  My
question is, what changes do I need to make in the configuration of a
Turbine 2.1 webapp to seamlessly use the OM classes generated by the
standalone Torque.  Do you have any documentation or suggestions on how
to perform this?

Thanks.  

-----Original Message-----
From: Pete Kazmier [mailto:pete@kazmier.com] 
Sent: Wednesday, January 23, 2002 5:16 PM
To: Turbine Users List
Subject: Re: Torque.Iniit() - Re: Help with Torque

Torque 3 has not been released yet.  However, you can always download
the source from the CVS repositories and build it yourself.  See the
section "Obtaining the Torque Distribution" in my tutorial:

http://www.kazmier.com/~kaz/torque/tutorial.html

Or, to save you the time and elaborate:

1.  Download the repository

    cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic login
    (password is anoncvs)
    cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic co
jakarta-turbine-torque

2.  Set lib.repo in your ${home}/build.properties file.  This should be
    a directory where you want to store all of the dependent jar files.

3.  ant update-jars

4.  ant dist

5.  Inside the bin directory you'll find 'torque-3.0-dev.zip', take that
    and unpack it somewhere.

Pete

On Wed, Jan 23, 2002 at 10:15:19PM +0000, stewart titan wrote:
> I've got the decoupled version of Torque - its the 2.x
> version.
> 
> http://jakarta.apache.org/builds/jakarta-turbine/release/2.1/
> 
> Where can I download version 3?
> 
> thanks.
>  --- Martin Poeschl <mp...@marmot.at> wrote: > 
> 
> > the Torque class only exists in the decoupled
> > version
> > if you want to use torque stand-alone you should use
> > 3.0-dev!!!!
> > 
> > cvs repo: jakarta-turbine-torque
> > 
> > martin
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
> 
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
> 

-- 
Peter Kazmier                                 http://www.kazmier.com
PGP Fingerprint   4FE7 8DA3 D0B5 9CAA 69DC  7243 1855 BC2E 4B43 5654

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Connecting to Postgres with Torque v3

Posted by Pete Kazmier <pe...@kazmier.com>.
On Thu, Jan 24, 2002 at 02:07:10PM +0000, stewart titan wrote:
> Also I'm wondering why the tutorial gives the example of:
> services.DatabaseService.bah.bah while the ??.properties config gives:
> 
> torque.database..bah.bah
> 
> Whats the difference?

What version of Torque are you using?  If you are using the standalone
(which is what the tutorial is for), then your run-time properties file
should have properties in the form of:

torque.database.*

If you are using the Torque that is coupled with Turbine, your run-time
propertise file should have properties in the form of:

services.DatabaseService.*

Again, the offer still stands, if you send me (to my email address) the
following:

    - build.properties
    - the contents of your schema directory
    - Torque.properties (the run-time properties)

I'd be happy to look at this in more detail for you.  I ran across the
same problem with my first app and it turned out to be something very
small (although I can't recall at the moment).

Thanks,
Pete

-- 
Peter Kazmier                                 http://www.kazmier.com
PGP Fingerprint   4FE7 8DA3 D0B5 9CAA 69DC  7243 1855 BC2E 4B43 5654

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Connecting to Postgres with Torque v3

Posted by stewart titan <st...@yahoo.co.uk>.
Hi

I've looked at the torque toturial, and copied and
pasted the run time *.properties file:

I've copied the postgres.jar to Torque/lib directory.

When I run my app -  which is largly the same as the
tutorial example, I get the following exception

connection = null

/usr/local/development/jbuilder4/jdk1.3/bin/java
-classpath
"/home/stewart/files/development/java/torquetest/classes:/usr/share/pgsql/jdbc7.0-1.2.jar:/home/stewart/files/development/java/torquetest/torque/lib/commons-collections.jar:/home/stewart/files/development/java/torquetest/torque/lib/commons-util-0.1-dev.jar:/home/stewart/files/development/java/torquetest/torque/lib/jdbc2_0-stdext.jar:/home/stewart/files/development/java/torquetest/torque/lib/log4j-1.1.3.jar:/home/stewart/files/development/java/torquetest/torque/lib/torque-3.0-dev.jar:/home/stewart/files/development/java/torquetest/torque/lib/velocity-1.3-dev.jar:/home/stewart/files/development/java/torquetest/torque/lib/village-1.5.3-dev.jar:/home/stewart/files/development/java/torquetest/torque/lib/xerces-1.4.4.jar:/usr/local/development/jbuilder4/jdk1.3/jre/lib/sunrsasign.jar:/usr/local/development/jbuilder4/jdk1.3/jre/lib/rt.jar:/usr/local/development/jbuilder4/jdk1.3/jre/lib/i18n.jar:/usr/local/development/jbuilder4/jdk1.3/jre/lib/javaplugin.jar:/usr/local/development/jbuilder4/jdk1.3/jre/lib/javaplugin_l10n.jar:/usr/local/development/jbuilder4/jdk1.3/lib/tools.jar:/usr/local/development/jbuilder4/jdk1.3/lib/dt.jar:/usr/local/development/jbuilder4/jdk1.3/demo/jfc/Java2D/Java2Demo.jar"
 org.stewarthector.TorqueTest.tester 
 connectin = null
java.lang.NullPointerException
	at
org.apache.torque.util.BasePeer.rollBackTransaction(BasePeer.java:375)
	at
org.stewarthector.TorqueTest.Entity.BaseApplication.save(BaseApplication.java:306)
	at
org.stewarthector.TorqueTest.Entity.BaseApplication.save(BaseApplication.java:285)
	at
org.stewarthector.TorqueTest.tester.doStuff(tester.java:37)
	at
org.stewarthector.TorqueTest.tester.main(tester.java:20)


It throws the exception on the dbCon = ... line
    public void save(String dbName) throws Exception
    {
        DBConnection dbCon = null;
         try
        {
            dbCon = BasePeer.beginTransaction(dbName);
            save(dbCon);
        }
        catch(Exception e)
        {
            BasePeer.rollBackTransaction(dbCon);
            throw e;
        }
        BasePeer.commitTransaction(dbCon);



Also I'm wondering why the tutorial gives the example
of:
services.DatabaseService.bah.bah
while the ??.properties config gives:

torque.database..bah.bah

Whats the difference?


Below are the settings I've changed in the
?.properties file:

services.DatabaseService.database.default=default

services.DatabaseService.database.default.driver=org.postgresql.Driver
services.DatabaseService.database.default.url=jdbc:postgresql://server/apps
services.DatabaseService.database.default.username=stewart
# These are the supported JDBC drivers and their
associated Turbine
# adapter.  These properties are used by the
DBFactory.  You can add
# all the drivers you want here.

services.DatabaseService.database.adapter=DBMM
services.DatabaseService.database.adapter.DBMM=org.postgresql.Driver


services.DatabaseService.database.idbroker.prefetch=true

services.DatabaseService.earlyInit = true

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Torque.Iniit() - Re: Help with Torque

Posted by Martin Poeschl <mp...@marmot.at>.
stewart titan wrote:
> How stable is versino 3?

during the last month all patches and enhancements were checked in to 3.0 only!!
and there is a testbed for 3.0 (which does not exist for 2.x)
it will also be used for turbine 2.2 and the stuff in turbine-2 will be deprecated

so i strongly recommend to use 3.0 if you want to use torque stand alone

> 
> Better to use the version 2.x?

NO!


martin

> 
> thanks
>  --- Pete Kazmier <pe...@kazmier.com> wrote: > Torque 3
> has not been released yet.  However, you
> 
>>can always download
>>the source from the CVS repositories and build it
>>yourself.  See the
>>section "Obtaining the Torque Distribution" in my
>>tutorial:
>>
>>http://www.kazmier.com/~kaz/torque/tutorial.html
>>
>>Or, to save you the time and elaborate:
>>
>>1.  Download the repository
>>
>>    cvs -d
>>:pserver:anoncvs@cvs.apache.org:/home/cvspublic
>>login
>>    (password is anoncvs)
>>    cvs -d
>>:pserver:anoncvs@cvs.apache.org:/home/cvspublic co
>>jakarta-turbine-torque
>>
>>2.  Set lib.repo in your ${home}/build.properties
>>file.  This should be
>>    a directory where you want to store all of the
>>dependent jar files.
>>
>>3.  ant update-jars
>>
>>4.  ant dist
>>
>>5.  Inside the bin directory you'll find
>>'torque-3.0-dev.zip', take that
>>    and unpack it somewhere.
>>
>>Pete
>>
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Torque.Iniit() - Re: Help with Torque

Posted by stewart titan <st...@yahoo.co.uk>.
How stable is versino 3?

Better to use the version 2.x?

thanks
 --- Pete Kazmier <pe...@kazmier.com> wrote: > Torque 3
has not been released yet.  However, you
> can always download
> the source from the CVS repositories and build it
> yourself.  See the
> section "Obtaining the Torque Distribution" in my
> tutorial:
> 
> http://www.kazmier.com/~kaz/torque/tutorial.html
> 
> Or, to save you the time and elaborate:
> 
> 1.  Download the repository
> 
>     cvs -d
> :pserver:anoncvs@cvs.apache.org:/home/cvspublic
> login
>     (password is anoncvs)
>     cvs -d
> :pserver:anoncvs@cvs.apache.org:/home/cvspublic co
> jakarta-turbine-torque
> 
> 2.  Set lib.repo in your ${home}/build.properties
> file.  This should be
>     a directory where you want to store all of the
> dependent jar files.
> 
> 3.  ant update-jars
> 
> 4.  ant dist
> 
> 5.  Inside the bin directory you'll find
> 'torque-3.0-dev.zip', take that
>     and unpack it somewhere.
> 
> Pete


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Torque.Iniit() - Re: Help with Torque

Posted by Pete Kazmier <pe...@kazmier.com>.
Torque 3 has not been released yet.  However, you can always download
the source from the CVS repositories and build it yourself.  See the
section "Obtaining the Torque Distribution" in my tutorial:

http://www.kazmier.com/~kaz/torque/tutorial.html

Or, to save you the time and elaborate:

1.  Download the repository

    cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic login
    (password is anoncvs)
    cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic co jakarta-turbine-torque

2.  Set lib.repo in your ${home}/build.properties file.  This should be
    a directory where you want to store all of the dependent jar files.

3.  ant update-jars

4.  ant dist

5.  Inside the bin directory you'll find 'torque-3.0-dev.zip', take that
    and unpack it somewhere.

Pete

On Wed, Jan 23, 2002 at 10:15:19PM +0000, stewart titan wrote:
> I've got the decoupled version of Torque - its the 2.x
> version.
> 
> http://jakarta.apache.org/builds/jakarta-turbine/release/2.1/
> 
> Where can I download version 3?
> 
> thanks.
>  --- Martin Poeschl <mp...@marmot.at> wrote: > 
> 
> > the Torque class only exists in the decoupled
> > version
> > if you want to use torque stand-alone you should use
> > 3.0-dev!!!!
> > 
> > cvs repo: jakarta-turbine-torque
> > 
> > martin
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 

-- 
Peter Kazmier                                 http://www.kazmier.com
PGP Fingerprint   4FE7 8DA3 D0B5 9CAA 69DC  7243 1855 BC2E 4B43 5654

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Torque.Iniit() - Re: Help with Torque

Posted by stewart titan <st...@yahoo.co.uk>.
I've got the decoupled version of Torque - its the 2.x
version.

http://jakarta.apache.org/builds/jakarta-turbine/release/2.1/

Where can I download version 3?

thanks.
 --- Martin Poeschl <mp...@marmot.at> wrote: > 

> the Torque class only exists in the decoupled
> version
> if you want to use torque stand-alone you should use
> 3.0-dev!!!!
> 
> cvs repo: jakarta-turbine-torque
> 
> martin
> 


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Torque.Iniit() - Re: Help with Torque

Posted by Martin Poeschl <mp...@marmot.at>.
stewart titan wrote:
> Hi Again,
> 
> One other thing, where is the Torque Class?
> 
> I've extracted all the .jar files, but cannot find a
> Torque.class (or .java) file.
> 
> Thank you for your help.
> 
> 
> Torque.init("ndb.properties");

there are 2 versions of torque!!!

2.2-dev which is part of turbine-2
3.0-dev which is the decoupled version (which will be used by turbine 2.2 and 3.0

the Torque class only exists in the decoupled version
if you want to use torque stand-alone you should use 3.0-dev!!!!

cvs repo: jakarta-turbine-torque

martin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Torque.Iniit() - Re: Help with Torque

Posted by stewart titan <st...@yahoo.co.uk>.
Hi Again,

One other thing, where is the Torque Class?

I've extracted all the .jar files, but cannot find a
Torque.class (or .java) file.

Thank you for your help.


Torque.init("ndb.properties");



__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Help with Torque

Posted by sbelt <sb...@velos.com>.
It is the file which defines the database connection info required by
Torque. Interestingly, this file (as I defined it in the .init) needs to be
in the directory from which you started tomcat -
so if you 'cd  <tomcat>/bin' and from there call startup.sh, the properties
file needs to be in this bin folder.


Below is the contents (I am connection to PostgreSql):

# -------------------------------------------------------------------
# Begin ndb.properties
# -------------------------------------------------------------------
# -------------------------------------------------------------------
#
#  D A T A B A S E  S E R V I C E
#
# -------------------------------------------------------------------
# These are your database settings.  Look in the
# org.apache.turbine.util.db.pool.* packages for more information.
# The default driver for Turbine is for MySQL.
#
# The parameters to connect to the default database.  You MUST
# configure these properly.
# -------------------------------------------------------------------

services.DatabaseService.database.default=ndb

services.DatabaseService.database.default.driver=org.postgresql.Driver
services.DatabaseService.database.default.url=jdbc:postgresql://localhost/nD
B
services.DatabaseService.database.default.username=postgres
services.DatabaseService.database.default.password=[put your password here]

services.DatabaseService.database.ndb.driver=org.postgresql.Driver
services.DatabaseService.database.ndb.url=jdbc:postgresql://localhost/nDB
services.DatabaseService.database.ndb.username=postgres
services.DatabaseService.database.ndb.password=

# The number of database connections to cache per ConnectionPool
# instance (specified per database).

services.DatabaseService.database.default.maxConnections=3

# The amount of time (in milliseconds) that database connections will be
# cached (specified per database).
#
# Default: one hour = 60 * 60 * 1000

services.DatabaseService.database.default.expiryTime=3600000

# The amount of time (in milliseconds) a connection request will have to
wait
# before a time out occurs and an error is thrown.
#
# Default: ten seconds = 10 * 1000

services.DatabaseService.database.connectionWaitTimeout=10000

# The interval (in milliseconds) between which the PoolBrokerService
logs
# the status of it's ConnectionPools.
#
# Default: No logging = 0 = 0 * 1000

services.DatabaseService.database.logInterval=0

# These are the supported JDBC drivers and their associated Turbine
# adapter.  These properties are used by the DBFactory.  You can add
# all the drivers you want here.

services.DatabaseService.database.adapter=DBPostgres
services.DatabaseService.database.adapter.DBPostgres=org.postgresql.Driver

# Determines if the quantity column of the IDBroker's id_table should
# be increased automatically if requests for ids reaches a high
# volume.

services.DatabaseService.database.idbroker.cleverquantity=true

# Determines if IDBroker should prefetch IDs or not.  If set to false
# this property has the effect of shutting off the housekeeping thread
# that attempts to prefetch the id's.  It also sets the # of id's
grabbed
# per request to 1 regardless of the settings in the database.
# Default: true

services.DatabaseService.database.idbroker.prefetch=true

services.DatabaseService.earlyInit = true


# -------------------------------------------------------------------
#
#  log4j
#
# -------------------------------------------------------------------
# Need to have log4j "appenders" for Torque or log4j will generate
# system out errors.
log4j.category.org.apache.torque = INFO, torque
log4j.appender.torque = org.apache.log4j.FileAppender
log4j.appender.torque.file = ./ndb.log
log4j.appender.torque.layout = org.apache.log4j.PatternLayout
log4j.appender.torque.layout.conversionPattern = %d [%t] %-5p %c - %m%n
log4j.appender.torque.append = false

# -------------------------------------------------------------------
# End ndb.properties
# -------------------------------------------------------------------

----- Original Message -----
From: "stewart titan" <st...@yahoo.co.uk>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Wednesday, January 23, 2002 10:23 AM
Subject: Re: Help with Torque


> Thank you so much for your reply.
>
> Looking through your code example, I am wondering
> what:
> ndb.properties is?
>
> Is it a file - if so what does it contain? thanks
> ndb.properties contains? , in:
>
> ( Torque.init("ndb.properties") );
>
>
> Thanks again.
>
>
>
>  --- sbelt <sb...@velos.com> wrote: > Let me start by
> saying that I am new to Torque as
> > well. But I did get an
> > application running (thanks in a large help to users
> > on this list). Here
> > would be my high-level view of how to use the
> > classes. If anyone disagrees
> > with me - believe THEM ;)
> >
> > Most of this is information I dug out of the site or
> > the Mail Archives which
> > was most useful to me.
> >
> > Suppose your schema.xml defined a table called
> > Address (I'll leave it to
> > your imagination to guess what fields would be in a
> > table with this name;).
> > You will find that Torque created files
> > BaseAddressPeer, AddressPeer,
> > BaseAddress, and Address.
> >
> > In your class constructor, add code which
> > initializes torque if it is not
> > already running. I used the following:
> > // setup torque for database access and pooling
> > try
> > {
> >    if ( !Torque.isInit() )
> >    {
> >         Torque.init("ndb.properties");
> >         System.out.println( "[MyClass.constructor()]
> > Torque.init completed
> > successfully\n");
> >     }
> >     else
> >     {
> >         System.out.println( "[MyClass.constructor()]
> > Torque.init is already
> > running\n");
> >     }
> > }
> > catch( Exception e )
> > {
> >     System.out.println( "[MyClass.constructor()]
> > error running
> > Torque.init:\n" + e );
> > }
> >
> > Now all you need to do is instantiate the Address
> > class, create criterias,
> > and parse results. (This is off the top of my head,
> > so consider it
> > pseudo-code at best):
> >
> > Address address = new Address();// you now have a
> > hook into all that Torque
> > functionality
> > Criteria criteria = new Criteria();
> > criteria.add(AddressPeer.LastName,
> > "Jones");//LastName was a field defined
> > in schema.xml
> > Vector v = AddressPeer.doSelect( criteria ); // v
> > contains a vector of
> > address objects
> > for (int x = 0; x<v.size; v++){
> >     String firstName =
> > ((Address)v.get(x)).getFirstName(); //FirstName is a
> > field defined by schema.xml
> >     String lastName =
> > ((Address)v.get(x)).getLastName(); //LastName is a
> > field defined by schema.xml
> >     System.out.println(lastName +", "+ firstName);
> > }
> >
> > If you need to start modifying the Torque code, here
> > are some pointers:
> >
> > The Base* files you should never have to change.
> > They are generated each
> > time you run torque, and may change if, for example,
> > you change databases.
> > BTW, the when you re-run torque, unless you deleted
> > them, the non-Base*
> > files are not overwritten.
> >
> > I am new to this as well, but I have not had to
> > modify any *Peer objects. I
> > get the feeling that you could add methods to this
> > file if you are sure they
> > are not db dependent.
> >
> > Most effort will be in the Address class (in our
> > example). When you look at
> > this class as generated by Torque, it simply extends
> > BaseAddress adding no
> > methods of its own. I used this in my case to create
> > selects from other
> > tables to fetch field-values for this insert (does
> > that make sense?). If I
> > re-run Torqe for a new database - because only the
> > Base* classes are
> > replaced - my code should continue to function!
> >
> > I HTH. As I said, I am still learning myself. My
> > experience so far has only
> > been in using the Torque-generated stuff, so I know
> > nothing of how Torque
> > itself works.  If you have any questions, I'll do my
> > best to share any
> > experince I might have in common.
> >
> > Steve B.
> > ----- Original Message -----
> > From: "stewart titan" <st...@yahoo.co.uk>
> > To: "Turbine Users List"
> > <tu...@jakarta.apache.org>
> > Sent: Wednesday, January 23, 2002 5:37 AM
> > Subject: Help with Torque
> >
> >
> > >
> > >  Hi
> > >
> > > (Apoloygise for the repost, but I forgot to change
> > the
> > > subject heading on my previous post)
> > >
> > >  Are there an small example applications etc of
> > how
> > >  to
> > >  use Torque?  I'm able to generate the classes and
> > >  sql,
> > >  but how to use the classes - the peer classes and
> > >  "non
> > >  peer" classes, ie,
> > >
> > >  There are two classes in which to put your own
> > code
> > >  in:
> > >  project
> > >  ProjectPeer
> > >
> > >  How do you use these? Ie, the code inside these
> > >  actually classes, the difference between the two,
> > >  and
> > >  how to use these classes in an application.
> > >
> > >  I've read the docs, but still, no help, using the
> > >  criteria etc is fine, but there are missing
> > examples
> > >  that I need to get going. So a sample application
> > >  would answer my questions.
> > >
> > >  Help is very much appreciated.
> > >
> > >  Thank You
> > >
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Everything you'll ever need on one web page
> > > from News and Sport to Email and Music Charts
> > > http://uk.my.yahoo.com
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
>
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Help with Torque

Posted by stewart titan <st...@yahoo.co.uk>.
Thank you so much for your reply.

Looking through your code example, I am wondering
what:
ndb.properties is?

Is it a file - if so what does it contain? thanks
ndb.properties contains? , in:

( Torque.init("ndb.properties") );


Thanks again.



 --- sbelt <sb...@velos.com> wrote: > Let me start by
saying that I am new to Torque as
> well. But I did get an
> application running (thanks in a large help to users
> on this list). Here
> would be my high-level view of how to use the
> classes. If anyone disagrees
> with me - believe THEM ;)
> 
> Most of this is information I dug out of the site or
> the Mail Archives which
> was most useful to me.
> 
> Suppose your schema.xml defined a table called
> Address (I'll leave it to
> your imagination to guess what fields would be in a
> table with this name;).
> You will find that Torque created files
> BaseAddressPeer, AddressPeer,
> BaseAddress, and Address.
> 
> In your class constructor, add code which
> initializes torque if it is not
> already running. I used the following:
> // setup torque for database access and pooling
> try
> {
>    if ( !Torque.isInit() )
>    {
>         Torque.init("ndb.properties");
>         System.out.println( "[MyClass.constructor()]
> Torque.init completed
> successfully\n");
>     }
>     else
>     {
>         System.out.println( "[MyClass.constructor()]
> Torque.init is already
> running\n");
>     }
> }
> catch( Exception e )
> {
>     System.out.println( "[MyClass.constructor()]
> error running
> Torque.init:\n" + e );
> }
> 
> Now all you need to do is instantiate the Address
> class, create criterias,
> and parse results. (This is off the top of my head,
> so consider it
> pseudo-code at best):
> 
> Address address = new Address();// you now have a
> hook into all that Torque
> functionality
> Criteria criteria = new Criteria();
> criteria.add(AddressPeer.LastName,
> "Jones");//LastName was a field defined
> in schema.xml
> Vector v = AddressPeer.doSelect( criteria ); // v
> contains a vector of
> address objects
> for (int x = 0; x<v.size; v++){
>     String firstName =
> ((Address)v.get(x)).getFirstName(); //FirstName is a
> field defined by schema.xml
>     String lastName =
> ((Address)v.get(x)).getLastName(); //LastName is a
> field defined by schema.xml
>     System.out.println(lastName +", "+ firstName);
> }
> 
> If you need to start modifying the Torque code, here
> are some pointers:
> 
> The Base* files you should never have to change.
> They are generated each
> time you run torque, and may change if, for example,
> you change databases.
> BTW, the when you re-run torque, unless you deleted
> them, the non-Base*
> files are not overwritten.
> 
> I am new to this as well, but I have not had to
> modify any *Peer objects. I
> get the feeling that you could add methods to this
> file if you are sure they
> are not db dependent.
> 
> Most effort will be in the Address class (in our
> example). When you look at
> this class as generated by Torque, it simply extends
> BaseAddress adding no
> methods of its own. I used this in my case to create
> selects from other
> tables to fetch field-values for this insert (does
> that make sense?). If I
> re-run Torqe for a new database - because only the
> Base* classes are
> replaced - my code should continue to function!
> 
> I HTH. As I said, I am still learning myself. My
> experience so far has only
> been in using the Torque-generated stuff, so I know
> nothing of how Torque
> itself works.  If you have any questions, I'll do my
> best to share any
> experince I might have in common.
> 
> Steve B.
> ----- Original Message -----
> From: "stewart titan" <st...@yahoo.co.uk>
> To: "Turbine Users List"
> <tu...@jakarta.apache.org>
> Sent: Wednesday, January 23, 2002 5:37 AM
> Subject: Help with Torque
> 
> 
> >
> >  Hi
> >
> > (Apoloygise for the repost, but I forgot to change
> the
> > subject heading on my previous post)
> >
> >  Are there an small example applications etc of
> how
> >  to
> >  use Torque?  I'm able to generate the classes and
> >  sql,
> >  but how to use the classes - the peer classes and
> >  "non
> >  peer" classes, ie,
> >
> >  There are two classes in which to put your own
> code
> >  in:
> >  project
> >  ProjectPeer
> >
> >  How do you use these? Ie, the code inside these
> >  actually classes, the difference between the two,
> >  and
> >  how to use these classes in an application.
> >
> >  I've read the docs, but still, no help, using the
> >  criteria etc is fine, but there are missing
> examples
> >  that I need to get going. So a sample application
> >  would answer my questions.
> >
> >  Help is very much appreciated.
> >
> >  Thank You
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Everything you'll ever need on one web page
> > from News and Sport to Email and Music Charts
> > http://uk.my.yahoo.com
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> 
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>  

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Help with Torque

Posted by stewart titan <st...@yahoo.co.uk>.
Thank you so much for your reply.

Looking through your code example, I am wondering
what:
ndb.properties is?

Is it a file - if so what does it contain? thanks
ndb.properties contains? , in:

( Torque.init("ndb.properties") );


Thanks again.



 --- sbelt <sb...@velos.com> wrote: > Let me start by
saying that I am new to Torque as
> well. But I did get an
> application running (thanks in a large help to users
> on this list). Here
> would be my high-level view of how to use the
> classes. If anyone disagrees
> with me - believe THEM ;)
> 
> Most of this is information I dug out of the site or
> the Mail Archives which
> was most useful to me.
> 
> Suppose your schema.xml defined a table called
> Address (I'll leave it to
> your imagination to guess what fields would be in a
> table with this name;).
> You will find that Torque created files
> BaseAddressPeer, AddressPeer,
> BaseAddress, and Address.
> 
> In your class constructor, add code which
> initializes torque if it is not
> already running. I used the following:
> // setup torque for database access and pooling
> try
> {
>    if ( !Torque.isInit() )
>    {
>         Torque.init("ndb.properties");
>         System.out.println( "[MyClass.constructor()]
> Torque.init completed
> successfully\n");
>     }
>     else
>     {
>         System.out.println( "[MyClass.constructor()]
> Torque.init is already
> running\n");
>     }
> }
> catch( Exception e )
> {
>     System.out.println( "[MyClass.constructor()]
> error running
> Torque.init:\n" + e );
> }
> 
> Now all you need to do is instantiate the Address
> class, create criterias,
> and parse results. (This is off the top of my head,
> so consider it
> pseudo-code at best):
> 
> Address address = new Address();// you now have a
> hook into all that Torque
> functionality
> Criteria criteria = new Criteria();
> criteria.add(AddressPeer.LastName,
> "Jones");//LastName was a field defined
> in schema.xml
> Vector v = AddressPeer.doSelect( criteria ); // v
> contains a vector of
> address objects
> for (int x = 0; x<v.size; v++){
>     String firstName =
> ((Address)v.get(x)).getFirstName(); //FirstName is a
> field defined by schema.xml
>     String lastName =
> ((Address)v.get(x)).getLastName(); //LastName is a
> field defined by schema.xml
>     System.out.println(lastName +", "+ firstName);
> }
> 
> If you need to start modifying the Torque code, here
> are some pointers:
> 
> The Base* files you should never have to change.
> They are generated each
> time you run torque, and may change if, for example,
> you change databases.
> BTW, the when you re-run torque, unless you deleted
> them, the non-Base*
> files are not overwritten.
> 
> I am new to this as well, but I have not had to
> modify any *Peer objects. I
> get the feeling that you could add methods to this
> file if you are sure they
> are not db dependent.
> 
> Most effort will be in the Address class (in our
> example). When you look at
> this class as generated by Torque, it simply extends
> BaseAddress adding no
> methods of its own. I used this in my case to create
> selects from other
> tables to fetch field-values for this insert (does
> that make sense?). If I
> re-run Torqe for a new database - because only the
> Base* classes are
> replaced - my code should continue to function!
> 
> I HTH. As I said, I am still learning myself. My
> experience so far has only
> been in using the Torque-generated stuff, so I know
> nothing of how Torque
> itself works.  If you have any questions, I'll do my
> best to share any
> experince I might have in common.
> 
> Steve B.
> ----- Original Message -----
> From: "stewart titan" <st...@yahoo.co.uk>
> To: "Turbine Users List"
> <tu...@jakarta.apache.org>
> Sent: Wednesday, January 23, 2002 5:37 AM
> Subject: Help with Torque
> 
> 
> >
> >  Hi
> >
> > (Apoloygise for the repost, but I forgot to change
> the
> > subject heading on my previous post)
> >
> >  Are there an small example applications etc of
> how
> >  to
> >  use Torque?  I'm able to generate the classes and
> >  sql,
> >  but how to use the classes - the peer classes and
> >  "non
> >  peer" classes, ie,
> >
> >  There are two classes in which to put your own
> code
> >  in:
> >  project
> >  ProjectPeer
> >
> >  How do you use these? Ie, the code inside these
> >  actually classes, the difference between the two,
> >  and
> >  how to use these classes in an application.
> >
> >  I've read the docs, but still, no help, using the
> >  criteria etc is fine, but there are missing
> examples
> >  that I need to get going. So a sample application
> >  would answer my questions.
> >
> >  Help is very much appreciated.
> >
> >  Thank You
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Everything you'll ever need on one web page
> > from News and Sport to Email and Music Charts
> > http://uk.my.yahoo.com
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> 
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>  

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Help with Torque

Posted by sbelt <sb...@velos.com>.
Let me start by saying that I am new to Torque as well. But I did get an
application running (thanks in a large help to users on this list). Here
would be my high-level view of how to use the classes. If anyone disagrees
with me - believe THEM ;)

Most of this is information I dug out of the site or the Mail Archives which
was most useful to me.

Suppose your schema.xml defined a table called Address (I'll leave it to
your imagination to guess what fields would be in a table with this name;).
You will find that Torque created files BaseAddressPeer, AddressPeer,
BaseAddress, and Address.

In your class constructor, add code which initializes torque if it is not
already running. I used the following:
// setup torque for database access and pooling
try
{
   if ( !Torque.isInit() )
   {
        Torque.init("ndb.properties");
        System.out.println( "[MyClass.constructor()] Torque.init completed
successfully\n");
    }
    else
    {
        System.out.println( "[MyClass.constructor()] Torque.init is already
running\n");
    }
}
catch( Exception e )
{
    System.out.println( "[MyClass.constructor()] error running
Torque.init:\n" + e );
}

Now all you need to do is instantiate the Address class, create criterias,
and parse results. (This is off the top of my head, so consider it
pseudo-code at best):

Address address = new Address();// you now have a hook into all that Torque
functionality
Criteria criteria = new Criteria();
criteria.add(AddressPeer.LastName, "Jones");//LastName was a field defined
in schema.xml
Vector v = AddressPeer.doSelect( criteria ); // v contains a vector of
address objects
for (int x = 0; x<v.size; v++){
    String firstName = ((Address)v.get(x)).getFirstName(); //FirstName is a
field defined by schema.xml
    String lastName = ((Address)v.get(x)).getLastName(); //LastName is a
field defined by schema.xml
    System.out.println(lastName +", "+ firstName);
}

If you need to start modifying the Torque code, here are some pointers:

The Base* files you should never have to change. They are generated each
time you run torque, and may change if, for example, you change databases.
BTW, the when you re-run torque, unless you deleted them, the non-Base*
files are not overwritten.

I am new to this as well, but I have not had to modify any *Peer objects. I
get the feeling that you could add methods to this file if you are sure they
are not db dependent.

Most effort will be in the Address class (in our example). When you look at
this class as generated by Torque, it simply extends BaseAddress adding no
methods of its own. I used this in my case to create selects from other
tables to fetch field-values for this insert (does that make sense?). If I
re-run Torqe for a new database - because only the Base* classes are
replaced - my code should continue to function!

I HTH. As I said, I am still learning myself. My experience so far has only
been in using the Torque-generated stuff, so I know nothing of how Torque
itself works.  If you have any questions, I'll do my best to share any
experince I might have in common.

Steve B.
----- Original Message -----
From: "stewart titan" <st...@yahoo.co.uk>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Wednesday, January 23, 2002 5:37 AM
Subject: Help with Torque


>
>  Hi
>
> (Apoloygise for the repost, but I forgot to change the
> subject heading on my previous post)
>
>  Are there an small example applications etc of how
>  to
>  use Torque?  I'm able to generate the classes and
>  sql,
>  but how to use the classes - the peer classes and
>  "non
>  peer" classes, ie,
>
>  There are two classes in which to put your own code
>  in:
>  project
>  ProjectPeer
>
>  How do you use these? Ie, the code inside these
>  actually classes, the difference between the two,
>  and
>  how to use these classes in an application.
>
>  I've read the docs, but still, no help, using the
>  criteria etc is fine, but there are missing examples
>  that I need to get going. So a sample application
>  would answer my questions.
>
>  Help is very much appreciated.
>
>  Thank You
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>