You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Marc Lustig <ma...@marclustig.com> on 2002/12/15 16:10:12 UTC

more patches to Extending User update (was AW: Documentation update)

Hi Quinton,
it's good to understand finally that the Turbine* om-classes are not needed
at all.
They don't need to be generated, as Turbine uses the classes that come along
with the org.apache.turbine package.
It's a miracle to me why the turbine-schema.xml file has not been removed in
the latest Turbine-release, or at least put into a separate dir to make
clear it is not needed (or rather must not) to be generated for a project.

Anyway, in order for the om-classes to compile I needed to add the following
changes to your patch:

1) TurbineUserAdapter.getUserId() must return int (not Integer)

    public int getUserId()
    {
        return ((NumberKey)getPrimaryKey()).intValue();
      //NOT: return new Integer(((NumberKey)getPrimaryKey()).intValue());
    }

since the Base* classes expect int values, not Integer.

2) TurbineUserAdapter needs to implements method setPrimaryKey:

    public void setPrimaryKey(String key) {
      try {
        super.setPrimaryKey(key);
      }
      catch (Exception ex) {
      }

since
org.apache.torque.om.BaseObject:
public void setPrimaryKey(java.lang.String primaryKey)
                   throws java.lang.Exception
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^

This relates to the fact that Torque is still evolving whereas the Turbine
Security System (org.apache.turbine.om.security.*) seems at stand still.

I will check tomorrow if this solution will work as it is supposed to do.

Greetings
Marc


> -----Ursprungliche Nachricht-----
> Von: Quinton McCombs [mailto:qmccombs@nequalsone.com]
> Gesendet: Sonntag, 15. Dezember 2002 02:37
> An: 'Turbine Users List'
> Betreff: RE: Documentation update
>
>
> Ahh...   You need to rename turbine-schema.xml to
> turbine-schema.xml.nogenerate (or anything besides *-schema.xml).  Next,
> delete all of the om.Turbine*, om.BaseTurbine*, om.map.Turbine* classes
> that were generated.  These classes are not used.  They only make things
> more confusing.
>
> Now, your schema file....  You should not list TURBINE_USER as a table
> in your schema file.  Instead, use AUDIOTEX_USER with an alias of
> TurbineUser.  This will cause AudiotexUser, AudiotexUserPeer, and the
> associated Base* classes to be generated.  The Base* classes will extend
> the adapters TurbineUserAdpater and TurbineUserPeerAdpaters,
> respectively.  Foreign key references in your schema file should use the
> table name AUDIOTEX_USER.
>
> I have made the appropriate changes to your schema file below.
>
>
> 	<table name="AUDIOTEX_USER" alias="TurbineUser"
> baseClass="de.geoconnect.audiotex.om.TurbineUserAdapter"
> basePeer="de.geoconnect.audiotex.om.TurbineUserPeerAdapter">
> 		<column name="USER_ID" primaryKey="true" required="true"
> type="INTEGER"/>
> 	</table>
> 	<table name="KUNDE">
> 		<column name="KUNDE_ID" primaryKey="true"
> required="true" type="INTEGER"/>
> 		<foreign-key foreignTable="AUDIOTEX_USER">
> 			<reference local="KUNDE_ID" foreign="USER_ID"/>
> 		</foreign-key>
> 	</table>
>
> This should get the om.* classes generating correctly for you.  On thing
> that I noticed is that the primary key of your KUNDE table is also the
> foreign key to AUDIOTEX_USER.  Was this your intent?  Perhaps you really
> just wanted to add a USER_ID column in the KUNDE table.  If so, change
> the definition of the KUNDE table as follows.
>
> 	<table name="KUNDE">
> 		<column name="KUNDE_ID" primaryKey="true"
> required="true" type="INTEGER"/>
> 		<column name="USER_ID" required="true" type="INTEGER"/>
> 		<foreign-key foreignTable="AUDIOTEX_USER">
> 			<reference local="USER_ID" foreign="USER_ID"/>
> 		</foreign-key>
> 	</table>
>
> After making those changes, run the project-om task again.  The only
> Turbine* or BaseTurbine* classes that you should have in your om package
> are TurbineUserAdapter and TurbineUserPeerAdapter.  You should not have
> any Turbine* classes in the om.map package.
>
>
> Just FYI, here is the exact syntax from my schema file.  The name of my
> extend turbine user class is called NeoUser.  I added clientId as a
> column in TURBINE_USER.
>
>     <table name="NEO_USER" alias="TurbineUser"
>            baseClass="com.nequalsone.om.TurbineUserAdapter"
>            basePeer="com.nequalsone.om.TurbineUserPeerAdapter">
>         <column name="USER_ID" required="true" primaryKey="true"
> type="INTEGER"/>
>     </table>
>     <table name="ADDRESS">
>         <column name="OBJECT_ID" primaryKey="true" required="true"
> type="INTEGER"/>
>         <column name="LINE_1" size="40" type="VARCHAR"/>
>         <column name="LINE_2" size="30" type="VARCHAR"/>
>         <column name="CITY" size="30" type="VARCHAR"/>
>         <column name="STATE" size="2" type="VARCHAR"/>
>         <column name="ZIP_CODE" size="5" type="VARCHAR"/>
>         <column name="ZIP_PLUS_4" size="4" type="VARCHAR"/>
>         <column name="CLIENT_ID" required="true" type="INTEGER"/>
>         <foreign-key foreignTable="CLIENT">
>             <reference foreign="OBJECT_ID" local="CLIENT_ID"/>
>         </foreign-key>
>     </table>
>
> Please let me know if this helps.
>
>
> -----Original Message-----
> From: Marc Lustig [mailto:mail@marclustig.com]
> Sent: Saturday, December 14, 2002 4:02 PM
> To: Turbine Users List
> Subject: AW: Documentation update
>
>
> Thanks, Quinton, that helped.
> However there is another problem: torque generates two classes in all of
> these files:
>
> BaseTurbineUser.java
> BaseTurbineUserPeer.java
> BaseTurbineUserManager.java
>
> For example, BaseTurbineUser.java contains both of these classes
>
> public abstract class BaseTurbineUser extends
> de.geoconnect.audiotex.om.TurbineUserAdapter
>     implements org.apache.turbine.om.Retrievable
> and
> public abstract class BaseTurbineUser extends BaseObject
>     implements org.apache.turbine.om.Retrievable
>
> Apparently what happens is that Torque generates object TurbineUser two
> times, first time from turbine-schema.xml, and second time from
> project-schema.xml.
>
>
> How did you got around this?
>
> My schema looks like this:
>
> 	<table name="TURBINE_USER" alias="AudiotexUser"
> baseClass="de.geoconnect.audiotex.om.TurbineUserAdapter"
> basePeer="de.geoconnect.audiotex.om.TurbineUserPeerAdapter">
> 		<column name="USER_ID" primaryKey="true" required="true"
> type="INTEGER"/>
> 	</table>
> 	<table name="KUNDE">
> 		<column name="KUNDE_ID" primaryKey="true"
> required="true" type="INTEGER"/>
> 		<foreign-key foreignTable="TURBINE_USER">
> 			<reference local="KUNDE_ID" foreign="USER_ID"/>
> 		</foreign-key>
> 	</table>
>
>
> Marc
>
>
>
> > -----Ursprungliche Nachricht-----
> > Von: Quinton McCombs [mailto:qmccombs@nequalsone.com]
> > Gesendet: Samstag, 14. Dezember 2002 22:25
> > An: 'Turbine Users List'
> > Betreff: RE: Documentation update
> >
> >
> > My applogies.  It should have been getTitle().  This is the attribute
> > that, in the example, we are adding to Turbine User.  Sorry, I guess
> > that was another reference that I over looked when converted the code
> > that I am using into the example.
> >
> > -----Original Message-----
> > From: Marc Lustig [mailto:mail@marclustig.com]
> > Sent: Saturday, December 14, 2002 2:16 PM
> > To: Turbine Users List
> > Subject: AW: Documentation update
> >
> >
> > Quinton, I tried out your Extend-User howto. I'm running into various
> > problems, but first of all: you have this method in your
> > TurbineMapBuilderAdapter
> >
> > public void doBuild() throws java.lang.Exception
> >     {
> >         super.doBuild();
> >
> >         // Make dummy object - required for adding a column to the map
> >         Integer integer = new Integer(0);
> >
> >         // Add extra User columns.
> >         TableMap tMap =
> > Torque.getDatabaseMap().getTable(getTableUser());
> >         tMap.addColumn(getClientId(),integer);
> >                        ^^^^^^^^^^^^
> >     }
> >
> > Problem is there is no method getCliendId() neither in
> > TurbineMapBuilderAdapter nor in
> > org.apache.turbine.util.db.map.TurbineMapBuilder.
> >
> > Could you please let me know how you implemented this method ? Thanks!
> >
> > Once, this is fixed all the other compilations errors might fade away.
> >
> > Marc
> >
> >
> > --
> > 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>
>
>
>
> --
> 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: Velocity Expression

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
"Eigen Technology Pty Ltd" <mi...@eigentechnology.com> writes:

>Alright guys, I may not sound very intelligent on this matter, but I am
>really frustrated with the outcome given by Velocity.  I changed A and C
>to VARCHAR and it worked!!

Yep. That's an ongoing source of frustration for Velocity newcomers and
seasoned users. Geir wants it that way and there is no way around it.

You might even check if it really checks the value against 3 (value
three) or "3" (string containing '3' char).

>But I am not really satisfied with this outcome, there must be a logical
>explanation to this, why INT works for some but not others?

Uh, there is a _longish_ thread about this in the velocity-dev
archives. I even had some patches for Velocity 1.1 at some point to
fix this behaviour which Geir didn't want.

Conclusion was "Velocity is a templating language, not a programming
language. If you do business logic in it, you're doing something
wrong". No, that's not _my_ opinion.

	Regards
		Henning
-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen       -- Geschaeftsfuehrer
INTERMETA - Gesellschaft fuer Mehrwertdienste mbH     hps@intermeta.de

Am Schwabachgrund 22  Fon.: 09131 / 50654-0   info@intermeta.de
D-91054 Buckenhof     Fax.: 09131 / 50654-20   

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


Re: Velocity Expression

Posted by Eigen Technology Pty Ltd <mi...@eigentechnology.com>.
Alright guys, I may not sound very intelligent on this matter, but I am
really frustrated with the outcome given by Velocity.  I changed A and C
to VARCHAR and it worked!!

But I am not really satisfied with this outcome, there must be a logical
explanation to this, why INT works for some but not others?

I am not unfamilia with programming, would really appreciate if anyone can
point out where I have done wrong.

best wishes
michael








> Thanks Wei,
>
> I have corrected the </tr> part, it gives the same result.
> Here is my schema file, I have modified it to A, B and C for the sake of
> simplicity, it is actually:
>
> <table name="INVOICEITEM">
>     <column name="ID" required="true" autoIncrement="true"
> primaryKey="true" type="INTEGER"/>
>     <column name="INVOICEREF" size="10" type="INTEGER"/>
>     <column name="CUSTOMERREF" size="10" type="INTEGER"/>
>     <column name="QUANTITY" size="10" type="INTEGER"/>
>     <column name="PARTICULAR" size="50" type="VARCHAR"/>
>     <column name="UNITPRICE" type="FLOAT"/>
>     <column name="TAX" type="FLOAT"/>
>     <column name="AMOUNT" type="FLOAT"/>
>     <column name="COMMENT" type="LONGVARCHAR"/>
>     <foreign-key foreignTable="CUSTOMER">
>     <reference local="QUANTIT2" foreign="ID"/>
>     </foreign-key>
>     <foreign-key foreignTable="INVOICE">
>     <reference local="INVOICEREF" foreign="ID"/>
>     </foreign-key>
>     </table>
>
> only Quantity worked, invoiceref, id, customerref, amount etc all failed
> the expression test.
>
> thanks
> michael
>
>
>
>
>>
>> what is your schema look like? also, i noticed that you <tr> should be
>> outside of inner #if #end block. this may cause problem in you
>> displayed result as well.  do a view source in you browser to see if
>> the syntax is
>>  correct.
>>
>>  >>>       #foreach ($entry in $entries)
>>  >>>        <tr>
>>  >>>        #if($entry.A == 3)
>>  >>>          #entryCell ($entry.Id)
>>  >>>          #entryCell ($entry.A)
>>  >>>          #entryCell ($entry.B)
>>  >>>          #entryCell ($entry.C)
>>  >>>        </tr>
>>  >>>       #end
>>  >>>       #end
>>  >>>
>>
>> Eigen Technology Pty Ltd wrote:
>>> Thanks,
>>>
>>> I tried your method, but I got the same result, i.e B is working, A
>>> and C do not work.  I tried to swap A and B in the database, again,
>>> only the new B worked, A still does not work.  Help would
>>> appreciated.
>>>
>>> best wishes
>>> michael
>>>
>>>
>>>
>>>
>>>
>>>>all of your A, B, and C are in fact Integer, the java Object, so try
>>>>
>>>>#if ($entry.A.intValue() == 3)
>>>>....
>>>>#end
>>>>
>>>>Eigen Technology Pty Ltd wrote:
>>>>
>>>>>Dear all,
>>>>>
>>>>>I have the following expression in one of my Velocity file:
>>>>>
>>>>>        #foreach ($entry in $entries)
>>>>>        <tr>
>>>>>        #if($entry.A == 3)
>>>>>          #entryCell ($entry.Id)
>>>>>          #entryCell ($entry.A)
>>>>>          #entryCell ($entry.B)
>>>>>          #entryCell ($entry.C)
>>>>>        </tr>
>>>>>       #end
>>>>>       #end
>>>>>
>>>>>the comparison expression only works for $entry.B, neither $entry.A
>>>>> nor $entry.C work, i.e. A and C return no result. All A, B and C
>>>>> are int. I have tried to compare as number (3) and text ("3"), only
>>>>> getting the same result.  What is limiting the expression? Would
>>>>> appreciate some hints.
>>>>>
>>>>>best wishes
>>>>>michael
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>--
>>>>>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>
>>>
>>
>>
>> --
>> Wei He, Ph.D.
>> Email: weihe@optonline.net
>> Voice: (845)359-5621
>> Fax:   (845)359-1631
>>
>>
>> --
>> 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: Velocity Expression

Posted by Rodney Schneider <ro...@actf.com.au>.
On Mon, 16 Dec 2002 16:26, you wrote:
> Thanks, that worked.
>
> These are crucial information that a website developer should know. I
> may have missed it in the documentations, if that is the case, please
> tell me where I can find info like that, so that I won't have to
> bother others.

Here is an exceprt from the TDK Howto:
"The java classes that Turbine uses to access your database are located
 in the directory "webapps/APPNAME/WEB-INF/src/java/PACKAGE/om" Look at 
 them to get an idea of how the object-model portion of Turbine
 operates. There should be one named after each of the tables that you
 defined above in your schema. These classes will be used to interact
 with the database while using Turbine."

Also see the Velocity User Guide:
http://jakarta.apache.org/velocity/user-guide.html

If you think the documentation should be clearer, you can always submit 
a patch :)

Regards,

-- Rodney

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


Re: Velocity Expression

Posted by Eigen Technology Pty Ltd <mi...@eigentechnology.com>.
Thanks, that worked.

These are crucial information that a website developer should know. I may
have missed it in the documentations, if that is the case, please tell me
where I can find info like that, so that I won't have to bother others.

best wishes
michael



>
> OK, the ref columns are foreign-key columns, they are returned as
> NumberKey object, all numeric primar keys in your tables are directly
> returned as NumberKey as well.
>
> Here is what you can do:
>
> $entry.A.getBigDecimal().intValue()
>
> this should fix the problem, this is exactly what I was suspecting.  I
> do not know if int actually gets returned for other cases as well,
> velocity handles Object only, not primitives, I think.
>
>
> Eigen Technology Pty Ltd wrote:
>> Thanks Wei,
>>
>> I have corrected the </tr> part, it gives the same result.
>> Here is my schema file, I have modified it to A, B and C for the sake
>> of simplicity, it is actually:
>>
>> <table name="INVOICEITEM">
>>     <column name="ID" required="true" autoIncrement="true"
>> primaryKey="true" type="INTEGER"/>
>>     <column name="INVOICEREF" size="10" type="INTEGER"/>
>>     <column name="CUSTOMERREF" size="10" type="INTEGER"/>
>>     <column name="QUANTITY" size="10" type="INTEGER"/>
>>     <column name="PARTICULAR" size="50" type="VARCHAR"/>
>>     <column name="UNITPRICE" type="FLOAT"/>
>>     <column name="TAX" type="FLOAT"/>
>>     <column name="AMOUNT" type="FLOAT"/>
>>     <column name="COMMENT" type="LONGVARCHAR"/>
>>     <foreign-key foreignTable="CUSTOMER">
>>     <reference local="QUANTIT2" foreign="ID"/>
>>     </foreign-key>
>>     <foreign-key foreignTable="INVOICE">
>>     <reference local="INVOICEREF" foreign="ID"/>
>>     </foreign-key>
>>     </table>
>>
>> only Quantity worked, invoiceref, id, customerref, amount etc all
>> failed the expression test.
>>
>> thanks
>> michael
>>
>>
>>
>>
>>
>>>what is your schema look like? also, i noticed that you <tr> should be
>>> outside of inner #if #end block. this may cause problem in you
>>> displayed result as well.  do a view source in you browser to see if
>>> the syntax is
>>> correct.
>>>
>>> >>>       #foreach ($entry in $entries)
>>> >>>        <tr>
>>> >>>        #if($entry.A == 3)
>>> >>>          #entryCell ($entry.Id)
>>> >>>          #entryCell ($entry.A)
>>> >>>          #entryCell ($entry.B)
>>> >>>          #entryCell ($entry.C)
>>> >>>        </tr>
>>> >>>       #end
>>> >>>       #end
>>> >>>
>>>
>>>Eigen Technology Pty Ltd wrote:
>>>
>>>>Thanks,
>>>>
>>>>I tried your method, but I got the same result, i.e B is working, A
>>>> and C do not work.  I tried to swap A and B in the database, again,
>>>> only the new B worked, A still does not work.  Help would
>>>> appreciated.
>>>>
>>>>best wishes
>>>>michael
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>all of your A, B, and C are in fact Integer, the java Object, so try
>>>>>
>>>>>#if ($entry.A.intValue() == 3)
>>>>>....
>>>>>#end
>>>>>
>>>>>Eigen Technology Pty Ltd wrote:
>>>>>
>>>>>
>>>>>>Dear all,
>>>>>>
>>>>>>I have the following expression in one of my Velocity file:
>>>>>>
>>>>>>       #foreach ($entry in $entries)
>>>>>>       <tr>
>>>>>>       #if($entry.A == 3)
>>>>>>         #entryCell ($entry.Id)
>>>>>>         #entryCell ($entry.A)
>>>>>>         #entryCell ($entry.B)
>>>>>>         #entryCell ($entry.C)
>>>>>>       </tr>
>>>>>>      #end
>>>>>>      #end
>>>>>>
>>>>>>the comparison expression only works for $entry.B, neither $entry.A
>>>>>> nor $entry.C work, i.e. A and C return no result. All A, B and C
>>>>>> are int. I have tried to compare as number (3) and text ("3"), only
>>>>>> getting the same result.  What is limiting the expression? Would
>>>>>> appreciate some hints.
>>>>>>
>>>>>>best wishes
>>>>>>michael
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>--
>>>>>>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>
>>>>
>>>
>>>--
>>>Wei He, Ph.D.
>>>Email: weihe@optonline.net
>>>Voice: (845)359-5621
>>>Fax:   (845)359-1631
>>>
>>>
>>>--
>>>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>
>>
>
>
> --
> Wei He, Ph.D.
> Email: weihe@optonline.net
> Voice: (845)359-5621
> Fax:   (845)359-1631
>
>
> --
> 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: Velocity Expression

Posted by Wei He <we...@ldeo.columbia.edu>.
OK, the ref columns are foreign-key columns, they are returned as 
NumberKey object, all numeric primar keys in your tables are directly 
returned as NumberKey as well.

Here is what you can do:

$entry.A.getBigDecimal().intValue()

this should fix the problem, this is exactly what I was suspecting.  I 
do not know if int actually gets returned for other cases as well, 
velocity handles Object only, not primitives, I think.


Eigen Technology Pty Ltd wrote:
> Thanks Wei,
> 
> I have corrected the </tr> part, it gives the same result.
> Here is my schema file, I have modified it to A, B and C for the sake of
> simplicity, it is actually:
> 
> <table name="INVOICEITEM">
>     <column name="ID" required="true" autoIncrement="true"
> primaryKey="true" type="INTEGER"/>
>     <column name="INVOICEREF" size="10" type="INTEGER"/>
>     <column name="CUSTOMERREF" size="10" type="INTEGER"/>
>     <column name="QUANTITY" size="10" type="INTEGER"/>
>     <column name="PARTICULAR" size="50" type="VARCHAR"/>
>     <column name="UNITPRICE" type="FLOAT"/>
>     <column name="TAX" type="FLOAT"/>
>     <column name="AMOUNT" type="FLOAT"/>
>     <column name="COMMENT" type="LONGVARCHAR"/>
>     <foreign-key foreignTable="CUSTOMER">
>     <reference local="QUANTIT2" foreign="ID"/>
>     </foreign-key>
>     <foreign-key foreignTable="INVOICE">
>     <reference local="INVOICEREF" foreign="ID"/>
>     </foreign-key>
>     </table>
> 
> only Quantity worked, invoiceref, id, customerref, amount etc all failed
> the expression test.
> 
> thanks
> michael
> 
> 
> 
> 
> 
>>what is your schema look like? also, i noticed that you <tr> should be
>>outside of inner #if #end block. this may cause problem in you displayed
>>result as well.  do a view source in you browser to see if the syntax is
>> correct.
>>
>> >>>       #foreach ($entry in $entries)
>> >>>        <tr>
>> >>>        #if($entry.A == 3)
>> >>>          #entryCell ($entry.Id)
>> >>>          #entryCell ($entry.A)
>> >>>          #entryCell ($entry.B)
>> >>>          #entryCell ($entry.C)
>> >>>        </tr>
>> >>>       #end
>> >>>       #end
>> >>>
>>
>>Eigen Technology Pty Ltd wrote:
>>
>>>Thanks,
>>>
>>>I tried your method, but I got the same result, i.e B is working, A
>>>and C do not work.  I tried to swap A and B in the database, again,
>>>only the new B worked, A still does not work.  Help would appreciated.
>>>
>>>best wishes
>>>michael
>>>
>>>
>>>
>>>
>>>
>>>
>>>>all of your A, B, and C are in fact Integer, the java Object, so try
>>>>
>>>>#if ($entry.A.intValue() == 3)
>>>>....
>>>>#end
>>>>
>>>>Eigen Technology Pty Ltd wrote:
>>>>
>>>>
>>>>>Dear all,
>>>>>
>>>>>I have the following expression in one of my Velocity file:
>>>>>
>>>>>       #foreach ($entry in $entries)
>>>>>       <tr>
>>>>>       #if($entry.A == 3)
>>>>>         #entryCell ($entry.Id)
>>>>>         #entryCell ($entry.A)
>>>>>         #entryCell ($entry.B)
>>>>>         #entryCell ($entry.C)
>>>>>       </tr>
>>>>>      #end
>>>>>      #end
>>>>>
>>>>>the comparison expression only works for $entry.B, neither $entry.A
>>>>>nor $entry.C work, i.e. A and C return no result. All A, B and C are
>>>>>int. I have tried to compare as number (3) and text ("3"), only
>>>>>getting the same result.  What is limiting the expression? Would
>>>>>appreciate some hints.
>>>>>
>>>>>best wishes
>>>>>michael
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>--
>>>>>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>
>>>
>>
>>--
>>Wei He, Ph.D.
>>Email: weihe@optonline.net
>>Voice: (845)359-5621
>>Fax:   (845)359-1631
>>
>>
>>--
>>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>
> 


-- 
Wei He, Ph.D.
Email: weihe@optonline.net
Voice: (845)359-5621
Fax:   (845)359-1631


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


Re: Velocity Expression

Posted by Eigen Technology Pty Ltd <mi...@eigentechnology.com>.
Thanks Wei,

I have corrected the </tr> part, it gives the same result.
Here is my schema file, I have modified it to A, B and C for the sake of
simplicity, it is actually:

<table name="INVOICEITEM">
    <column name="ID" required="true" autoIncrement="true"
primaryKey="true" type="INTEGER"/>
    <column name="INVOICEREF" size="10" type="INTEGER"/>
    <column name="CUSTOMERREF" size="10" type="INTEGER"/>
    <column name="QUANTITY" size="10" type="INTEGER"/>
    <column name="PARTICULAR" size="50" type="VARCHAR"/>
    <column name="UNITPRICE" type="FLOAT"/>
    <column name="TAX" type="FLOAT"/>
    <column name="AMOUNT" type="FLOAT"/>
    <column name="COMMENT" type="LONGVARCHAR"/>
    <foreign-key foreignTable="CUSTOMER">
    <reference local="QUANTIT2" foreign="ID"/>
    </foreign-key>
    <foreign-key foreignTable="INVOICE">
    <reference local="INVOICEREF" foreign="ID"/>
    </foreign-key>
    </table>

only Quantity worked, invoiceref, id, customerref, amount etc all failed
the expression test.

thanks
michael




>
> what is your schema look like? also, i noticed that you <tr> should be
> outside of inner #if #end block. this may cause problem in you displayed
> result as well.  do a view source in you browser to see if the syntax is
>  correct.
>
>  >>>       #foreach ($entry in $entries)
>  >>>        <tr>
>  >>>        #if($entry.A == 3)
>  >>>          #entryCell ($entry.Id)
>  >>>          #entryCell ($entry.A)
>  >>>          #entryCell ($entry.B)
>  >>>          #entryCell ($entry.C)
>  >>>        </tr>
>  >>>       #end
>  >>>       #end
>  >>>
>
> Eigen Technology Pty Ltd wrote:
>> Thanks,
>>
>> I tried your method, but I got the same result, i.e B is working, A
>> and C do not work.  I tried to swap A and B in the database, again,
>> only the new B worked, A still does not work.  Help would appreciated.
>>
>> best wishes
>> michael
>>
>>
>>
>>
>>
>>>all of your A, B, and C are in fact Integer, the java Object, so try
>>>
>>>#if ($entry.A.intValue() == 3)
>>>....
>>>#end
>>>
>>>Eigen Technology Pty Ltd wrote:
>>>
>>>>Dear all,
>>>>
>>>>I have the following expression in one of my Velocity file:
>>>>
>>>>        #foreach ($entry in $entries)
>>>>        <tr>
>>>>        #if($entry.A == 3)
>>>>          #entryCell ($entry.Id)
>>>>          #entryCell ($entry.A)
>>>>          #entryCell ($entry.B)
>>>>          #entryCell ($entry.C)
>>>>        </tr>
>>>>       #end
>>>>       #end
>>>>
>>>>the comparison expression only works for $entry.B, neither $entry.A
>>>> nor $entry.C work, i.e. A and C return no result. All A, B and C are
>>>> int. I have tried to compare as number (3) and text ("3"), only
>>>> getting the same result.  What is limiting the expression? Would
>>>> appreciate some hints.
>>>>
>>>>best wishes
>>>>michael
>>>>
>>>>
>>>>
>>>>
>>>>--
>>>>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>
>>
>
>
> --
> Wei He, Ph.D.
> Email: weihe@optonline.net
> Voice: (845)359-5621
> Fax:   (845)359-1631
>
>
> --
> 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: Velocity Expression

Posted by Wei He <we...@ldeo.columbia.edu>.
what is your schema look like? also, i noticed that you <tr> should be 
outside of inner #if #end block. this may cause problem in you displayed
result as well.  do a view source in you browser to see if the syntax is 
correct.

 >>>       #foreach ($entry in $entries)
 >>>        <tr>
 >>>        #if($entry.A == 3)
 >>>          #entryCell ($entry.Id)
 >>>          #entryCell ($entry.A)
 >>>          #entryCell ($entry.B)
 >>>          #entryCell ($entry.C)
 >>>        </tr>
 >>>       #end
 >>>       #end
 >>>

Eigen Technology Pty Ltd wrote:
> Thanks,
> 
> I tried your method, but I got the same result, i.e B is working, A and C
> do not work.  I tried to swap A and B in the database, again, only the new
> B worked, A still does not work.  Help would appreciated.
> 
> best wishes
> michael
> 
> 
> 
> 
> 
>>all of your A, B, and C are in fact Integer, the java Object, so
>>try
>>
>>#if ($entry.A.intValue() == 3)
>>....
>>#end
>>
>>Eigen Technology Pty Ltd wrote:
>>
>>>Dear all,
>>>
>>>I have the following expression in one of my Velocity file:
>>>
>>>        #foreach ($entry in $entries)
>>>        <tr>
>>>        #if($entry.A == 3)
>>>          #entryCell ($entry.Id)
>>>          #entryCell ($entry.A)
>>>          #entryCell ($entry.B)
>>>          #entryCell ($entry.C)
>>>        </tr>
>>>       #end
>>>       #end
>>>
>>>the comparison expression only works for $entry.B, neither $entry.A
>>>nor $entry.C work, i.e. A and C return no result. All A, B and C are
>>>int. I have tried to compare as number (3) and text ("3"), only
>>>getting the same result.  What is limiting the expression? Would
>>>appreciate some hints.
>>>
>>>best wishes
>>>michael
>>>
>>>
>>>
>>>
>>>--
>>>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>
> 


-- 
Wei He, Ph.D.
Email: weihe@optonline.net
Voice: (845)359-5621
Fax:   (845)359-1631


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


Re: Velocity Expression

Posted by Eigen Technology Pty Ltd <mi...@eigentechnology.com>.
Thanks,

I tried your method, but I got the same result, i.e B is working, A and C
do not work.  I tried to swap A and B in the database, again, only the new
B worked, A still does not work.  Help would appreciated.

best wishes
michael




> all of your A, B, and C are in fact Integer, the java Object, so
> try
>
> #if ($entry.A.intValue() == 3)
> ....
> #end
>
> Eigen Technology Pty Ltd wrote:
>> Dear all,
>>
>> I have the following expression in one of my Velocity file:
>>
>>         #foreach ($entry in $entries)
>>         <tr>
>>         #if($entry.A == 3)
>>           #entryCell ($entry.Id)
>>           #entryCell ($entry.A)
>>           #entryCell ($entry.B)
>>           #entryCell ($entry.C)
>>         </tr>
>>        #end
>>        #end
>>
>> the comparison expression only works for $entry.B, neither $entry.A
>> nor $entry.C work, i.e. A and C return no result. All A, B and C are
>> int. I have tried to compare as number (3) and text ("3"), only
>> getting the same result.  What is limiting the expression? Would
>> appreciate some hints.
>>
>> best wishes
>> michael
>>
>>
>>
>>
>> --
>> 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: Velocity Expression

Posted by Eigen Technology Pty Ltd <mi...@eigentechnology.com>.
I am really baffled by this Velocity behaviour ...

The returned valued from the BaseXXX.java file for value A, B and C are
all int. However, only only condition for test B works, I tried:

#if ($entry.A < 0)

and

#if ($entry.A > 0)

both failed. This indicates that $entry.A is probably not even an integer
or numerical value. What is the type for return value like this? And why
does B work and not A ??

getting really confused here.

thanks for any help
michael





>
> all of your A, B, and C are in fact Integer, the java Object, so
> try
>
> #if ($entry.A.intValue() == 3)
> ....
> #end
>
> Eigen Technology Pty Ltd wrote:
>> Dear all,
>>
>> I have the following expression in one of my Velocity file:
>>
>>         #foreach ($entry in $entries)
>>         <tr>
>>         #if($entry.A == 3)
>>           #entryCell ($entry.Id)
>>           #entryCell ($entry.A)
>>           #entryCell ($entry.B)
>>           #entryCell ($entry.C)
>>         </tr>
>>        #end
>>        #end
>>
>> the comparison expression only works for $entry.B, neither $entry.A
>> nor $entry.C work, i.e. A and C return no result. All A, B and C are
>> int. I have tried to compare as number (3) and text ("3"), only
>> getting the same result.  What is limiting the expression? Would
>> appreciate some hints.
>>
>> best wishes
>> michael
>>
>>
>>
>>
>> --
>> 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: Velocity Expression

Posted by Wei He <we...@ldeo.columbia.edu>.
all of your A, B, and C are in fact Integer, the java Object, so
try

#if ($entry.A.intValue() == 3)
....
#end

Eigen Technology Pty Ltd wrote:
> Dear all,
> 
> I have the following expression in one of my Velocity file:
> 
>         #foreach ($entry in $entries)
>         <tr>
>         #if($entry.A == 3)
>           #entryCell ($entry.Id)
>           #entryCell ($entry.A)
>           #entryCell ($entry.B)
>           #entryCell ($entry.C)
>         </tr>
>        #end
>        #end
> 
> the comparison expression only works for $entry.B, neither $entry.A nor
> $entry.C work, i.e. A and C return no result. All A, B and C are int. I
> have tried to compare as number (3) and text ("3"), only getting the same
> result.  What is limiting the expression? Would appreciate some hints.
> 
> best wishes
> michael
> 
> 
> 
> 
> --
> 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>


Velocity Expression

Posted by Eigen Technology Pty Ltd <mi...@eigentechnology.com>.
Dear all,

I have the following expression in one of my Velocity file:

        #foreach ($entry in $entries)
        <tr>
        #if($entry.A == 3)
          #entryCell ($entry.Id)
          #entryCell ($entry.A)
          #entryCell ($entry.B)
          #entryCell ($entry.C)
        </tr>
       #end
       #end

the comparison expression only works for $entry.B, neither $entry.A nor
$entry.C work, i.e. A and C return no result. All A, B and C are int. I
have tried to compare as number (3) and text ("3"), only getting the same
result.  What is limiting the expression? Would appreciate some hints.

best wishes
michael




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


Re: AW: more patches to Extending User update (was AW: Documentation update)

Posted by Rodney Schneider <ro...@actf.com.au>.
On Mon, 16 Dec 2002 12:31, you wrote:

> I tried with defaultJavaType="object".
> It works except for type tinyint. Torque generates things like Byte
> xx = new Byte(0); which does not work as Byte doesn't have a
> constructor for int. These columns need to be specified as
> javaType="primitive", e.g. <column name="GLOBAL_AVAILABILITY"
> type="TINYINT" size="1" default="0" javaType="primitive"/>
>
> I use mysql which has no support for boolean, so I simulate this
> using tinyint 1.
> It would be cool if Torque would allow a mapping to boolean.

Hi Marc,

See this post:
http://archives.apache.org/eyebrowse/ReadMsg?listName=turbine-torque-dev@jakarta.apache.org&msgNo=2162

If this fixes your problem, could you submit a patch to Scarab?

Thanks,

-- Rodney

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


RE: more patches to Extending User update (was AW: Documentation update)

Posted by Quinton McCombs <qm...@nequalsone.com>.
Torque has booleanchar and booleanint.  It does not generate the code
correctly for either one though.  I created a defect issue in scarab for
it and submitted a patch.  So far one one of the two file that need to
be patched have been.

> -----Original Message-----
> From: Marc Lustig [mailto:mail@marclustig.com] 
> Sent: Sunday, December 15, 2002 7:31 PM
> To: Turbine Users List
> Subject: AW: more patches to Extending User update (was AW: 
> Documentation update)
> 
> 
> > > That's interesting to know. What is the exact xml-syntax? Is it 
> > > specified in the database-element like this? <database 
> > > defaultJavaType="object"> Is it possible to specifiy this 
> for each 
> > > table individually? Probably this would cause trouble with 
> > > TurbineUserAdapter.
> > >
> >
> > You are correct with the syntax.  For the table it is 
> > javaType="object". The code given in the how-to is based on using 
> > defaultJavaType="object" for your project.  The implementation of 
> > TurbineUser in the o.a.t.om.security package is using primatives.
> 
> I tried with defaultJavaType="object".
> It works except for type tinyint. Torque generates things 
> like Byte xx = new Byte(0); which does not work as Byte 
> doesn't have a constructor for int. These columns need to be 
> specified as javaType="primitive", e.g. <column 
> name="GLOBAL_AVAILABILITY" type="TINYINT" size="1" 
> default="0" javaType="primitive"/>
> 
> I use mysql which has no support for boolean, so I simulate 
> this using tinyint 1. It would be cool if Torque would allow 
> a mapping to boolean.
> 
> 
> Marc
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:turbine-user-> unsubscribe@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>


AW: more patches to Extending User update (was AW: Documentation update)

Posted by Marc Lustig <ma...@marclustig.com>.
> > That's interesting to know. What is the exact xml-syntax?
> > Is it specified in the database-element like this?
> > <database defaultJavaType="object">
> > Is it possible to specifiy this for each table individually?
> > Probably this would cause trouble with TurbineUserAdapter.
> >
>
> You are correct with the syntax.  For the table it is javaType="object".
> The code given in the how-to is based on using defaultJavaType="object"
> for your project.  The implementation of TurbineUser in the
> o.a.t.om.security package is using primatives.

I tried with defaultJavaType="object".
It works except for type tinyint. Torque generates things like Byte xx = new
Byte(0); which does not work as Byte doesn't have a constructor for int.
These columns need to be specified as javaType="primitive", e.g.
<column name="GLOBAL_AVAILABILITY" type="TINYINT" size="1" default="0"
javaType="primitive"/>

I use mysql which has no support for boolean, so I simulate this using
tinyint 1.
It would be cool if Torque would allow a mapping to boolean.


Marc


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


RE: more patches to Extending User update (was AW: Documentation update)

Posted by Quinton McCombs <qm...@nequalsone.com>.
> -----Original Message-----
> From: Marc Lustig [mailto:mail@marclustig.com] 
> Sent: Sunday, December 15, 2002 3:47 PM
> To: Turbine Users List
> Subject: AW: more patches to Extending User update (was AW: 
> Documentation update)
> 
> 

<snip>

> > > since the Base* classes expect int values, not Integer.
> >
> > This is caused by the javaType of you extended user table 
> definition.  
> > I set the defaultJavaType in my database tag to "object".  
> I think you 
> > are using "primitive" which is the default.  I use the 
> other setting 
> > simply because it is impossible to have a field defined as 
> an int with 
> > a null value.  The same is true for other data types as well.
> 
> That's interesting to know. What is the exact xml-syntax?
> Is it specified in the database-element like this?
> <database defaultJavaType="object">
> Is it possible to specifiy this for each table individually? 
> Probably this would cause trouble with TurbineUserAdapter.
> 

You are correct with the syntax.  For the table it is javaType="object".
The code given in the how-to is based on using defaultJavaType="object"
for your project.  The implementation of TurbineUser in the
o.a.t.om.security package is using primatives.


> Maybe I will try to change this in my project and get back to Integer.
> 
> 
> Marc
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:turbine-user-> unsubscribe@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>


AW: more patches to Extending User update (was AW: Documentation update)

Posted by Marc Lustig <ma...@marclustig.com>.
> > Hi Quinton,
> > it's good to understand finally that the Turbine* om-classes
> > are not needed at all. They don't need to be generated, as
> > Turbine uses the classes that come along with the
> > org.apache.turbine package. It's a miracle to me why the
> > turbine-schema.xml file has not been removed in the latest
> > Turbine-release, or at least put into a separate dir to make
> > clear it is not needed (or rather must not) to be generated
> > for a project.
>
> The turbine-schema.xml file, I think, is still used for the ant task to
> create you database for you.  I probably need to figure out how to keep

Yeah, you are right. I forgot about that.

> Torque from generating objects from it but still allow it to be used to
> generate database schemas.  I am assuming that you manually added the
> column to TURBINE_USER in the database as I did.

For now I didn't add any field to turbine_user. I need only the foreign key.
Rather maybe I will try later to delete some of the fields of turbine_user.
Btw, my table kunde is an extension of the user, and therefore has kunde_id
both as the foreign key to turbine_user and primary key.

> > Anyway, in order for the om-classes to compile I needed to
> > add the following changes to your patch:
> >
> > 1) TurbineUserAdapter.getUserId() must return int (not Integer)
> >
> >     public int getUserId()
> >     {
> >         return ((NumberKey)getPrimaryKey()).intValue();
> >       //NOT: return new
> > Integer(((NumberKey)getPrimaryKey()).intValue());
> >     }
> >
> > since the Base* classes expect int values, not Integer.
>
> This is caused by the javaType of you extended user table definition.  I
> set the defaultJavaType in my database tag to "object".  I think you are
> using "primitive" which is the default.  I use the other setting simply
> because it is impossible to have a field defined as an int with a null
> value.  The same is true for other data types as well.

That's interesting to know. What is the exact xml-syntax?
Is it specified in the database-element like this?
<database defaultJavaType="object">
Is it possible to specifiy this for each table individually? Probably this
would cause trouble with TurbineUserAdapter.

Maybe I will try to change this in my project and get back to Integer.


Marc


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


RE: more patches to Extending User update (was AW: Documentation update)

Posted by Quinton McCombs <qm...@nequalsone.com>.
> -----Original Message-----
> From: Marc Lustig [mailto:mail@marclustig.com] 
> Sent: Sunday, December 15, 2002 9:10 AM
> To: Turbine Users List
> Subject: more patches to Extending User update (was AW: 
> Documentation update)
> 
> 
> Hi Quinton,
> it's good to understand finally that the Turbine* om-classes 
> are not needed at all. They don't need to be generated, as 
> Turbine uses the classes that come along with the 
> org.apache.turbine package. It's a miracle to me why the 
> turbine-schema.xml file has not been removed in the latest 
> Turbine-release, or at least put into a separate dir to make 
> clear it is not needed (or rather must not) to be generated 
> for a project.

The turbine-schema.xml file, I think, is still used for the ant task to
create you database for you.  I probably need to figure out how to keep
Torque from generating objects from it but still allow it to be used to
generate database schemas.  I am assuming that you manually added the
column to TURBINE_USER in the database as I did.

> 
> Anyway, in order for the om-classes to compile I needed to 
> add the following changes to your patch:
> 
> 1) TurbineUserAdapter.getUserId() must return int (not Integer)
> 
>     public int getUserId()
>     {
>         return ((NumberKey)getPrimaryKey()).intValue();
>       //NOT: return new 
> Integer(((NumberKey)getPrimaryKey()).intValue());
>     }
> 
> since the Base* classes expect int values, not Integer.

This is caused by the javaType of you extended user table definition.  I
set the defaultJavaType in my database tag to "object".  I think you are
using "primitive" which is the default.  I use the other setting simply
because it is impossible to have a field defined as an int with a null
value.  The same is true for other data types as well.  

I will point out this possible variation in my how-to.

> 
> 2) TurbineUserAdapter needs to implements method setPrimaryKey:
> 
>     public void setPrimaryKey(String key) {
>       try {
>         super.setPrimaryKey(key);
>       }
>       catch (Exception ex) {
>       }
> 
> since
> org.apache.torque.om.BaseObject:
> public void setPrimaryKey(java.lang.String primaryKey)
>                    throws java.lang.Exception
>                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> This relates to the fact that Torque is still evolving 
> whereas the Turbine Security System 
> (org.apache.turbine.om.security.*) seems at stand still.

Thanks.  I will look into this one.  

> 
> I will check tomorrow if this solution will work as it is 
> supposed to do.
> 

Please let me know how it works for you.  

> Greetings
> Marc
> 
> 
> > -----Ursprungliche Nachricht-----
> > Von: Quinton McCombs [mailto:qmccombs@nequalsone.com]
> > Gesendet: Sonntag, 15. Dezember 2002 02:37
> > An: 'Turbine Users List'
> > Betreff: RE: Documentation update
> >
> >
> > Ahh...   You need to rename turbine-schema.xml to
> > turbine-schema.xml.nogenerate (or anything besides *-schema.xml).  
> > Next, delete all of the om.Turbine*, om.BaseTurbine*, 
> om.map.Turbine* 
> > classes that were generated.  These classes are not used.  
> They only 
> > make things more confusing.
> >
> > Now, your schema file....  You should not list TURBINE_USER 
> as a table 
> > in your schema file.  Instead, use AUDIOTEX_USER with an alias of 
> > TurbineUser.  This will cause AudiotexUser, 
> AudiotexUserPeer, and the 
> > associated Base* classes to be generated.  The Base* classes will 
> > extend the adapters TurbineUserAdpater and TurbineUserPeerAdpaters, 
> > respectively.  Foreign key references in your schema file 
> should use 
> > the table name AUDIOTEX_USER.
> >
> > I have made the appropriate changes to your schema file below.
> >
> >
> > 	<table name="AUDIOTEX_USER" alias="TurbineUser" 
> > baseClass="de.geoconnect.audiotex.om.TurbineUserAdapter"
> > basePeer="de.geoconnect.audiotex.om.TurbineUserPeerAdapter">
> > 		<column name="USER_ID" primaryKey="true" 
> required="true" 
> > type="INTEGER"/>
> > 	</table>
> > 	<table name="KUNDE">
> > 		<column name="KUNDE_ID" primaryKey="true"
> > required="true" type="INTEGER"/>
> > 		<foreign-key foreignTable="AUDIOTEX_USER">
> > 			<reference local="KUNDE_ID" foreign="USER_ID"/>
> > 		</foreign-key>
> > 	</table>
> >
> > This should get the om.* classes generating correctly for you.  On 
> > thing that I noticed is that the primary key of your KUNDE table is 
> > also the foreign key to AUDIOTEX_USER.  Was this your 
> intent?  Perhaps 
> > you really just wanted to add a USER_ID column in the KUNDE 
> table.  If 
> > so, change the definition of the KUNDE table as follows.
> >
> > 	<table name="KUNDE">
> > 		<column name="KUNDE_ID" primaryKey="true"
> > required="true" type="INTEGER"/>
> > 		<column name="USER_ID" required="true" type="INTEGER"/>
> > 		<foreign-key foreignTable="AUDIOTEX_USER">
> > 			<reference local="USER_ID" foreign="USER_ID"/>
> > 		</foreign-key>
> > 	</table>
> >
> > After making those changes, run the project-om task again.  The only
> > Turbine* or BaseTurbine* classes that you should have in your om 
> > package are TurbineUserAdapter and TurbineUserPeerAdapter.  
> You should 
> > not have any Turbine* classes in the om.map package.
> >
> >
> > Just FYI, here is the exact syntax from my schema file.  
> The name of 
> > my extend turbine user class is called NeoUser.  I added 
> clientId as a 
> > column in TURBINE_USER.
> >
> >     <table name="NEO_USER" alias="TurbineUser"
> >            baseClass="com.nequalsone.om.TurbineUserAdapter"
> >            basePeer="com.nequalsone.om.TurbineUserPeerAdapter">
> >         <column name="USER_ID" required="true" primaryKey="true" 
> > type="INTEGER"/>
> >     </table>
> >     <table name="ADDRESS">
> >         <column name="OBJECT_ID" primaryKey="true" required="true" 
> > type="INTEGER"/>
> >         <column name="LINE_1" size="40" type="VARCHAR"/>
> >         <column name="LINE_2" size="30" type="VARCHAR"/>
> >         <column name="CITY" size="30" type="VARCHAR"/>
> >         <column name="STATE" size="2" type="VARCHAR"/>
> >         <column name="ZIP_CODE" size="5" type="VARCHAR"/>
> >         <column name="ZIP_PLUS_4" size="4" type="VARCHAR"/>
> >         <column name="CLIENT_ID" required="true" type="INTEGER"/>
> >         <foreign-key foreignTable="CLIENT">
> >             <reference foreign="OBJECT_ID" local="CLIENT_ID"/>
> >         </foreign-key>
> >     </table>
> >
> > Please let me know if this helps.
> >
> >
> > -----Original Message-----
> > From: Marc Lustig [mailto:mail@marclustig.com]
> > Sent: Saturday, December 14, 2002 4:02 PM
> > To: Turbine Users List
> > Subject: AW: Documentation update
> >
> >
> > Thanks, Quinton, that helped.
> > However there is another problem: torque generates two 
> classes in all 
> > of these files:
> >
> > BaseTurbineUser.java
> > BaseTurbineUserPeer.java
> > BaseTurbineUserManager.java
> >
> > For example, BaseTurbineUser.java contains both of these classes
> >
> > public abstract class BaseTurbineUser extends 
> > de.geoconnect.audiotex.om.TurbineUserAdapter
> >     implements org.apache.turbine.om.Retrievable
> > and
> > public abstract class BaseTurbineUser extends BaseObject
> >     implements org.apache.turbine.om.Retrievable
> >
> > Apparently what happens is that Torque generates object TurbineUser 
> > two times, first time from turbine-schema.xml, and second time from 
> > project-schema.xml.
> >
> >
> > How did you got around this?
> >
> > My schema looks like this:
> >
> > 	<table name="TURBINE_USER" alias="AudiotexUser" 
> > baseClass="de.geoconnect.audiotex.om.TurbineUserAdapter"
> > basePeer="de.geoconnect.audiotex.om.TurbineUserPeerAdapter">
> > 		<column name="USER_ID" primaryKey="true" 
> required="true" 
> > type="INTEGER"/>
> > 	</table>
> > 	<table name="KUNDE">
> > 		<column name="KUNDE_ID" primaryKey="true"
> > required="true" type="INTEGER"/>
> > 		<foreign-key foreignTable="TURBINE_USER">
> > 			<reference local="KUNDE_ID" foreign="USER_ID"/>
> > 		</foreign-key>
> > 	</table>
> >
> >
> > Marc
> >
> >
> >
> > > -----Ursprungliche Nachricht-----
> > > Von: Quinton McCombs [mailto:qmccombs@nequalsone.com]
> > > Gesendet: Samstag, 14. Dezember 2002 22:25
> > > An: 'Turbine Users List'
> > > Betreff: RE: Documentation update
> > >
> > >
> > > My applogies.  It should have been getTitle().  This is the 
> > > attribute that, in the example, we are adding to Turbine User.  
> > > Sorry, I guess that was another reference that I over looked when 
> > > converted the code that I am using into the example.
> > >
> > > -----Original Message-----
> > > From: Marc Lustig [mailto:mail@marclustig.com]
> > > Sent: Saturday, December 14, 2002 2:16 PM
> > > To: Turbine Users List
> > > Subject: AW: Documentation update
> > >
> > >
> > > Quinton, I tried out your Extend-User howto. I'm running into 
> > > various problems, but first of all: you have this method in your 
> > > TurbineMapBuilderAdapter
> > >
> > > public void doBuild() throws java.lang.Exception
> > >     {
> > >         super.doBuild();
> > >
> > >         // Make dummy object - required for adding a 
> column to the map
> > >         Integer integer = new Integer(0);
> > >
> > >         // Add extra User columns.
> > >         TableMap tMap = 
> > > Torque.getDatabaseMap().getTable(getTableUser());
> > >         tMap.addColumn(getClientId(),integer);
> > >                        ^^^^^^^^^^^^
> > >     }
> > >
> > > Problem is there is no method getCliendId() neither in 
> > > TurbineMapBuilderAdapter nor in 
> > > org.apache.turbine.util.db.map.TurbineMapBuilder.
> > >
> > > Could you please let me know how you implemented this method ? 
> > > Thanks!
> > >
> > > Once, this is fixed all the other compilations errors might fade 
> > > away.
> > >
> > > Marc
> > >
> > >
> > > --
> > > 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>
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
> 
> 
> --
> To 
> unsubscribe, e-mail:   
> <mailto:turbine-user-> unsubscribe@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>