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" <[EMAIL PROTECTED]>
> To: "Turbine Users List" <[EMAIL PROTECTED]>
> 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:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
>
>
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>