You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Sean Leach <sl...@netlojix.com> on 2001/06/06 06:32:36 UTC

Torque Question

This may be a silly question, but why does Torque generate lowercase Java
variable names on all columns in the object schema?

For example, if I have a column named "datePosted", I would assume I would
get the resulting java var to be datePosted, with getDatePosted() etc.
following normal Java naming scheme, instead I get dateposted and
getDateposted()

I know I can change it in the Object.vm file etc., but I was just curious
why that decision was made.  There may be something I am missing...

Forgive me if so :)

Sean


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Torque Question

Posted by Sean Leach <sl...@netlojix.com>.
Ahhh - gees, I should have thought of that considering I used it for the
table element...

Thanks for the info :)

Sean

-----Original Message-----
From: turbine-user-return-2305-sleach=netlojix.com@jakarta.apache.org
[mailto:turbine-user-return-2305-sleach=netlojix.com@jakarta.apache.org]
On Behalf Of Mike Haberman
Sent: Tuesday, June 05, 2001 10:06 PM
To: turbine-user@jakarta.apache.org
Subject: Re: Torque Question


you can use the javeName attribute:

e.g. <column name="dateposted" javaName="DatePosted" ... />

mike

On Tue, Jun 05, 2001 at 09:32:36PM -0700, Sean Leach wrote:
> This may be a silly question, but why does Torque generate lowercase Java
> variable names on all columns in the object schema?
>
> For example, if I have a column named "datePosted", I would assume I would
> get the resulting java var to be datePosted, with getDatePosted() etc.
> following normal Java naming scheme, instead I get dateposted and
> getDateposted()
>
> I know I can change it in the Object.vm file etc., but I was just curious
> why that decision was made.  There may be something I am missing...
>
> Forgive me if so :)
>
> Sean
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

--
-------------------------------------------------
I am Vinz, Vinz Clortho.  Keymaster of Gozer,
Volguus Zildrohar, Lord of the Sebouillia.
Are you the Gatekeeper?
-------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Torque Question

Posted by Mike Haberman <mi...@ncsa.uiuc.edu>.
you can use the javeName attribute:

e.g. <column name="dateposted" javaName="DatePosted" ... />

mike

On Tue, Jun 05, 2001 at 09:32:36PM -0700, Sean Leach wrote:
> This may be a silly question, but why does Torque generate lowercase Java
> variable names on all columns in the object schema?
> 
> For example, if I have a column named "datePosted", I would assume I would
> get the resulting java var to be datePosted, with getDatePosted() etc.
> following normal Java naming scheme, instead I get dateposted and
> getDateposted()
> 
> I know I can change it in the Object.vm file etc., but I was just curious
> why that decision was made.  There may be something I am missing...
> 
> Forgive me if so :)
> 
> Sean
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

-- 
-------------------------------------------------
I am Vinz, Vinz Clortho.  Keymaster of Gozer,
Volguus Zildrohar, Lord of the Sebouillia.
Are you the Gatekeeper?
-------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Torque Question

Posted by Edward Nunez <Ed...@oracle.com>.
Hi,

In the SQL "world", column names with several words are usually
separated by underlines "_"

Torque uses this naming convention to generate java variable names, and
getters and setters are generated with each word with the first char in
uppercase
and removes underlines,

Following your example, if you have a SQL column called DATE_POSTED,
Torque will generate a private variable named "date_posted" and following
methods "getDatePosted()", "setDatePosted(...)". This value would be
accessible
from Velocity as "DatePosted", or "getDatePosted()".

Hope this helps,

Regards,

Edward.

Sean Leach wrote:

> This may be a silly question, but why does Torque generate lowercase Java
> variable names on all columns in the object schema?
>
> For example, if I have a column named "datePosted", I would assume I would
> get the resulting java var to be datePosted, with getDatePosted() etc.
> following normal Java naming scheme, instead I get dateposted and
> getDateposted()
>
> I know I can change it in the Object.vm file etc., but I was just curious
> why that decision was made.  There may be something I am missing...
>
> Forgive me if so :)
>
> Sean
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Help needed with id_broker and foreign keys

Posted by James Coltman <ja...@majorband.co.uk>.
See my other post called 'Torque question' which also answers this question.

Cheers,

James

-----Original Message-----
From: James Coltman [mailto:james_coltman@majorband.co.uk]
Sent: 07 June 2001 16:16
To: turbine-user@jakarta.apache.org
Subject: RE: Help needed with id_broker and foreign keys


This is the way in which I thought it should work. But when I try to access
the primary key after
executing the doInsert method its value is still set to null. Having stepped
through the code it would
appear that this is because the buildCriteria( Foo obj ) method in the
generated peer is setting
the primary key value to null i.e criteria.add(  FOO_ID , obj.getFooId() ).

This means that the branch:
	if (!criteria.containsKey(pk.getFullyQualifiedName()))

will return false and no key will be generated.

I also don't see that if this was not occuring, and the key was generated,
how the primary key in Foo object
would be set to the newly generated value.

As usual any help given would be much appreciated.

James

-----Original Message-----
From: jmcnally [mailto:jmcnally]On Behalf Of John McNally
Sent: 06 June 2001 18:50
To: turbine-user@jakarta.apache.org
Subject: Re: Help needed with id_broker and foreign keys


If you have an object Foo and you call foo.save() or use the Peer
directly and call FooPeer.doInsert(foo);  foo will then have its id set
and it is available through either getPrimaryKey() or through the
column getter ( e.g. getFooId() ).

john mcnally

James Coltman wrote:
>
> Hi,
>
> I use the id_broker to create unique id for each new row. In order to
> populate my foreign keys on other tables I need to use this newly created
> id. When you create a new row entry how do you find out the id that was
> allocated to that entry? Is the only way to do a second select to get back
> the newly created row (an id)? I assume someone must have come across this
> before. Any help would be much appreciated.
>
> James
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Torque Question

Posted by "Frank W. Nolden" <fr...@maxware.nl>.
What is in your schema.xml?

  ----- Original Message ----- 
  From: James Coltman 
  To: turbine-user@jakarta.apache.org 
  Sent: Thursday, June 07, 2001 18:29
  Subject: Torque Question


  I am using Torque on Windows 2000 with MySql and TDK 2.1. When I look in the
  generated map file I always get the following line in doBuild method:

   tMap.setPrimaryKeyMethod(TableMap.NONE);

  How do I get this to say TableMap.IDBROKERTABLE or TableMap.AUTOINCREMENT?
  It doesn't seem to make any difference as to what I put in schema.xml for
  the table. Has anyone else come across this problem and do they have a
  solution?

  Any help would be much appreciated.

  James


  ---------------------------------------------------------------------
  To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
  For additional commands, e-mail: turbine-user-help@jakarta.apache.org



Re: Torque Question

Posted by Gary Lawrence Murphy <ga...@canada.com>.
Thanks for that tip ... it arrived right in the nick of time ;)

Can someone post a very short tutorial (or link to such) on using the
ID Broker?

For example, my application requires billions of IDs, with only tens
of millions active at any one time.  Is this a good use for the ID
Broker (when set to use BIGINT) Does it re-use old unused numbers?

-- 
Gary Lawrence Murphy <ga...@teledyn.com> TeleDynamics Communications Inc
Business Innovations Through Open Source Systems: http://www.teledyn.com
"Computers are useless.  They can only give you answers."(Pablo Picasso)


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Torque Question

Posted by "Frank W. Nolden" <fr...@maxware.nl>.
  <table name="CIF" idMethod="sequence">
    <column name="CIF_ID" required="true" autoIncrement="true" primaryKey="true" type="BIGINT"/>
    <column name="CIF_Name" required="true" size="50" type="VARCHAR"/>

This is a code snippet for those who want to know....
  ----- Original Message ----- 
  From: James Coltman 
  To: Turbine-User@Jakarta. Apache. Org 
  Sent: Thursday, June 07, 2001 18:50
  Subject: RE: Torque Question


  Answered my own question. There has is a idMethod attribute that you add to
  the table tag to specify the increment method to use. i.e.:

  <table name="Foo" idMethod="idbroker">

  or

  <table name="Foo" idMethod="autoincrement">

  or

  <table name="Foo" idMethod="sequence">

  Hope this helps someone else when they get stuck.


  James


  ---------------------------------------------------------------------
  To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
  For additional commands, e-mail: turbine-user-help@jakarta.apache.org



RE: Torque Question

Posted by James Coltman <ja...@majorband.co.uk>.
Answered my own question. There has is a idMethod attribute that you add to
the table tag to specify the increment method to use. i.e.:

<table name="Foo" idMethod="idbroker">

or

<table name="Foo" idMethod="autoincrement">

or

<table name="Foo" idMethod="sequence">

Hope this helps someone else when they get stuck.


James


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Torque Question

Posted by James Coltman <ja...@majorband.co.uk>.
I am using Torque on Windows 2000 with MySql and TDK 2.1. When I look in the
generated map file I always get the following line in doBuild method:

 tMap.setPrimaryKeyMethod(TableMap.NONE);

How do I get this to say TableMap.IDBROKERTABLE or TableMap.AUTOINCREMENT?
It doesn't seem to make any difference as to what I put in schema.xml for
the table. Has anyone else come across this problem and do they have a
solution?

Any help would be much appreciated.

James


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Help needed with id_broker and foreign keys

Posted by James Coltman <ja...@majorband.co.uk>.
This is the way in which I thought it should work. But when I try to access
the primary key after
executing the doInsert method its value is still set to null. Having stepped
through the code it would
appear that this is because the buildCriteria( Foo obj ) method in the
generated peer is setting
the primary key value to null i.e criteria.add(  FOO_ID , obj.getFooId() ).

This means that the branch:
	if (!criteria.containsKey(pk.getFullyQualifiedName()))

will return false and no key will be generated.

I also don't see that if this was not occuring, and the key was generated,
how the primary key in Foo object
would be set to the newly generated value.

As usual any help given would be much appreciated.

James

-----Original Message-----
From: jmcnally [mailto:jmcnally]On Behalf Of John McNally
Sent: 06 June 2001 18:50
To: turbine-user@jakarta.apache.org
Subject: Re: Help needed with id_broker and foreign keys


If you have an object Foo and you call foo.save() or use the Peer
directly and call FooPeer.doInsert(foo);  foo will then have its id set
and it is available through either getPrimaryKey() or through the
column getter ( e.g. getFooId() ).

john mcnally

James Coltman wrote:
>
> Hi,
>
> I use the id_broker to create unique id for each new row. In order to
> populate my foreign keys on other tables I need to use this newly created
> id. When you create a new row entry how do you find out the id that was
> allocated to that entry? Is the only way to do a second select to get back
> the newly created row (an id)? I assume someone must have come across this
> before. Any help would be much appreciated.
>
> James
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Help needed with id_broker and foreign keys

Posted by John McNally <jm...@collab.net>.
If you have an object Foo and you call foo.save() or use the Peer
directly and call FooPeer.doInsert(foo);  foo will then have its id set
and it is available through either getPrimaryKey() or through the 
column getter ( e.g. getFooId() ).

john mcnally

James Coltman wrote:
> 
> Hi,
> 
> I use the id_broker to create unique id for each new row. In order to
> populate my foreign keys on other tables I need to use this newly created
> id. When you create a new row entry how do you find out the id that was
> allocated to that entry? Is the only way to do a second select to get back
> the newly created row (an id)? I assume someone must have come across this
> before. Any help would be much appreciated.
> 
> James
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: Help needed with id_broker and foreign keys

Posted by Sean Leach <sl...@netlojix.com>.
>From the Peer HOWTO
(http://jakarta.apache.org/turbine/howto/peers-howto.html)

....
To do an insert we need to add all the fields to the criteria objects. Note
that the id field is not added to the Criteria. It is taken care of by the
ID BROKER. The object that is returned by doInsert is the id of the newly
added row.

Criteria crit = new Criteria();
crit.add (CategoryPeer.NAME,"New Category");
Object o = CategoryPeer.doInsert (crit);



Sean

-----Original Message-----
From: turbine-user-return-2310-sleach=netlojix.com@jakarta.apache.org
[mailto:turbine-user-return-2310-sleach=netlojix.com@jakarta.apache.org]
On Behalf Of James Coltman
Sent: Wednesday, June 06, 2001 7:23 AM
To: turbine-user@jakarta.apache.org
Subject: Help needed with id_broker and foreign keys


Hi,

I use the id_broker to create unique id for each new row. In order to
populate my foreign keys on other tables I need to use this newly created
id. When you create a new row entry how do you find out the id that was
allocated to that entry? Is the only way to do a second select to get back
the newly created row (an id)? I assume someone must have come across this
before. Any help would be much appreciated.


James



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Help needed with id_broker and foreign keys

Posted by James Coltman <ja...@majorband.co.uk>.
Hi,

I use the id_broker to create unique id for each new row. In order to
populate my foreign keys on other tables I need to use this newly created
id. When you create a new row entry how do you find out the id that was
allocated to that entry? Is the only way to do a second select to get back
the newly created row (an id)? I assume someone must have come across this
before. Any help would be much appreciated.


James



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org