You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Alexis HAUMONT <al...@smile.fr> on 2001/04/05 18:36:15 UTC

BigDecimal PK fields treated as StringKey by BasePeer

Hi all !

I'm joining the Turbine force after several home-made java web
applications..
seems like you've done a great job !

As We're just building our first app, we used the latest TDK and build
all our peer objects with Torque, everything  went great.. 
With several more Torque/Velocity-templates  we've build the basics of 
our application with default Action/Screen/templates for each tables.. 

But I have one question related to the mapping between SQL Types and 
Java types : why are my INTEGER SQL type mapped to Java 'int' ??
How do I handle NULL SQL values ??

I've found out that if I declare my field as NUMERIC in my xml-schema, the 
mapping use BigDecimal which I definitely prefer.

But with all my fields declared as BigDecimals, i've encountered a bug
in BasePeer.doInsert(), which returned a StringKey Object for my NUMERIC PK.

I'm new to Turbine, so maybe I'm misunderstanding something, but by changing
this one line in BasePeer everything went great :


Index: BasePeer.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine/src/java/org/apache/turbine/om/peer/BasePeer
.java,v
retrieving revision 1.50
diff -u -r1.50 BasePeer.java
--- BasePeer.java	2001/04/05 04:46:46	1.50
+++ BasePeer.java	2001/04/05 16:12:24
@@ -718,7 +718,7 @@
             // before the insert.
             if (keyGen.isPriorToInsert())
             {
-                if ( pk.getType() instanceof Integer ) 
+                if ( pk.getType() instanceof Number ) 
                 {
                     id = new NumberKey( tableMap.getIdGenerator()
                         .getIdAsBigDecimal(dbCon.getConnection(), keyInfo)
); 




Index: BasePeer.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine/src/java/org/apache/turbine/om/peer/BasePeer
.java,v
retrieving revision 1.50
diff -u -r1.50 BasePeer.java
--- BasePeer.java	2001/04/05 04:46:46	1.50
+++ BasePeer.java	2001/04/05 16:12:24
@@ -718,7 +718,7 @@
             // before the insert.
             if (keyGen.isPriorToInsert())
             {
-                if ( pk.getType() instanceof Integer ) 
+                if ( pk.getType() instanceof Number ) 
                 {
                     id = new NumberKey( tableMap.getIdGenerator()
                         .getIdAsBigDecimal(dbCon.getConnection(), keyInfo)
); 

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


Re: BigDecimal PK fields treated as StringKey by BasePeer

Posted by "Frank W. Nolden" <fr...@maxware.nl>.
Sorry about the html. Will try to remember.
I am using Torque stand alone, but will get the complete TDK (with Torque)
to run this test again.
Thanks for this pointer.
Will report the results later.

Frank


----- Original Message -----
From: John McNally
To: turbine-user@jakarta.apache.org
Sent: Thursday, April 05, 2001 20:57
Subject: Re: BigDecimal PK fields treated as StringKey by BasePeer


please turn off html email to this list.

the tdk has torque integrated.  If you are using torque in standalone
mode you can grab cvs of turbine to get the latest version.  cvs is
tagged to match tdk releases if you want to grab the one used to create
the tdk you are using.

John McNally

---------------------------------------------------------------------
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: BigDecimal PK fields treated as StringKey by BasePeer

Posted by John McNally <jm...@collab.net>.
please turn off html email to this list.

the tdk has torque integrated.  If you are using torque in standalone
mode you can grab cvs of turbine to get the latest version.  cvs is
tagged to match tdk releases if you want to grab the one used to create
the tdk you are using.

John McNally

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


Re: BigDecimal PK fields treated as StringKey by BasePeer

Posted by "Frank W. Nolden" <fr...@maxware.nl>.
I know it is not related to the patch, but since Alexis succeeded in building the classes it could of any help to me. I am using the Torque 1.1a12. Can you then tell me which TDK to use with this Torque version? That might do the trick.
Regards,

Frank
  ----- Original Message ----- 
  From: John McNally 
  To: turbine-user@jakarta.apache.org 
  Sent: Thursday, April 05, 2001 20:35
  Subject: Re: BigDecimal PK fields treated as StringKey by BasePeer


  This error appears to me like you have an old turbine jar in your
  classpath.  I do not think it is related to the patch Alexis described.

  "Frank W. Nolden" wrote:
  > 
  > Hi Alexis,
  > 
  > sorry to contact you directly off the list, but I haven't had any reply to
  > my question and it seems that Torque is working fine with you. Maybe I am
  > doing something completely wrong, but maybe not.
  > 
  > I have been succesfully generating the om and the SQL scripts with Torque
  > 1.1a12 (although there are some minor issues with the last character being
  > deleted in the generated Create Tabel statements). Now I want to build the
  > generated code, but I find the following errors.
  > Any help is apreciated.
  > 
  > Frank
  > 
  >     [javac] C:\fls\tmp\src\com\maxware\fls\om\BaseAcc.java:27: Interface
  > com.maxware.fls.om.Retrievable of class com.maxware.fls.om.BaseAcc not
  > found.
  >     [javac]     implements Retrievable
  >     [javac]                ^
  >     [javac] C:\fls\tmp\src\com\maxware\fls\om\Acc.java:28: Interface
  > com.maxware.fls.om.Persistent of class com.maxware.fls.om.Acc not found.
  >     [javac]     implements Persistent
  >     [javac]                ^
  >     [javac] C:\fls\tmp\src\com\maxware\fls\om\BaseAccPeer.java:109: The
  > method org.apache.turbine.om.ObjectKey
  > doInsert(org.apache.turbine.util.db.Criteria) declared in class
  > com.maxware.fls.om.BaseAccPeer cannot override the method of the same
  > signature declared in class org.apache.turbine.om.peer.BasePeer.  They must
  > have the same return type.
  >     [javac]     public static ObjectKey doInsert( Criteria criteria ) throws
  > Exception
  >     [javac]                             ^
  >     [javac] C:\fls\tmp\src\com\maxware\fls\om\BaseAccPeer.java:120: The
  > method org.apache.turbine.om.ObjectKey
  > doInsert(org.apache.turbine.util.db.Criteria,
  > org.apache.turbine.util.db.pool.DBConnection) declared in class
  > com.maxware.fls.om.BaseAccPeer cannot override the method of the same
  > signature declared in class org.apache.turbine.om.peer.BasePeer.  They must
  > have the same return type.
  >     [javac]     public static ObjectKey doInsert( Criteria criteria,
  > DBConnection dbCon )
  >     [javac]                             ^
  >     [javac] C:\fls\tmp\src\com\maxware\fls\om\BaseApc.java:27: Interface
  > com.maxware.fls.om.Retrievable of class com.maxware.fls.om.BaseApc not
  > found.

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



Re: BigDecimal PK fields treated as StringKey by BasePeer

Posted by John McNally <jm...@collab.net>.
This error appears to me like you have an old turbine jar in your
classpath.  I do not think it is related to the patch Alexis described.

"Frank W. Nolden" wrote:
> 
> Hi Alexis,
> 
> sorry to contact you directly off the list, but I haven't had any reply to
> my question and it seems that Torque is working fine with you. Maybe I am
> doing something completely wrong, but maybe not.
> 
> I have been succesfully generating the om and the SQL scripts with Torque
> 1.1a12 (although there are some minor issues with the last character being
> deleted in the generated Create Tabel statements). Now I want to build the
> generated code, but I find the following errors.
> Any help is apreciated.
> 
> Frank
> 
>     [javac] C:\fls\tmp\src\com\maxware\fls\om\BaseAcc.java:27: Interface
> com.maxware.fls.om.Retrievable of class com.maxware.fls.om.BaseAcc not
> found.
>     [javac]     implements Retrievable
>     [javac]                ^
>     [javac] C:\fls\tmp\src\com\maxware\fls\om\Acc.java:28: Interface
> com.maxware.fls.om.Persistent of class com.maxware.fls.om.Acc not found.
>     [javac]     implements Persistent
>     [javac]                ^
>     [javac] C:\fls\tmp\src\com\maxware\fls\om\BaseAccPeer.java:109: The
> method org.apache.turbine.om.ObjectKey
> doInsert(org.apache.turbine.util.db.Criteria) declared in class
> com.maxware.fls.om.BaseAccPeer cannot override the method of the same
> signature declared in class org.apache.turbine.om.peer.BasePeer.  They must
> have the same return type.
>     [javac]     public static ObjectKey doInsert( Criteria criteria ) throws
> Exception
>     [javac]                             ^
>     [javac] C:\fls\tmp\src\com\maxware\fls\om\BaseAccPeer.java:120: The
> method org.apache.turbine.om.ObjectKey
> doInsert(org.apache.turbine.util.db.Criteria,
> org.apache.turbine.util.db.pool.DBConnection) declared in class
> com.maxware.fls.om.BaseAccPeer cannot override the method of the same
> signature declared in class org.apache.turbine.om.peer.BasePeer.  They must
> have the same return type.
>     [javac]     public static ObjectKey doInsert( Criteria criteria,
> DBConnection dbCon )
>     [javac]                             ^
>     [javac] C:\fls\tmp\src\com\maxware\fls\om\BaseApc.java:27: Interface
> com.maxware.fls.om.Retrievable of class com.maxware.fls.om.BaseApc not
> found.

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


Re: BigDecimal PK fields treated as StringKey by BasePeer

Posted by "Frank W. Nolden" <fr...@maxware.nl>.
Hi Alexis,

sorry to contact you directly off the list, but I haven't had any reply to
my question and it seems that Torque is working fine with you. Maybe I am
doing something completely wrong, but maybe not.

I have been succesfully generating the om and the SQL scripts with Torque
1.1a12 (although there are some minor issues with the last character being
deleted in the generated Create Tabel statements). Now I want to build the
generated code, but I find the following errors.
Any help is apreciated.

Frank


    [javac] C:\fls\tmp\src\com\maxware\fls\om\BaseAcc.java:27: Interface
com.maxware.fls.om.Retrievable of class com.maxware.fls.om.BaseAcc not
found.
    [javac]     implements Retrievable
    [javac]                ^
    [javac] C:\fls\tmp\src\com\maxware\fls\om\Acc.java:28: Interface
com.maxware.fls.om.Persistent of class com.maxware.fls.om.Acc not found.
    [javac]     implements Persistent
    [javac]                ^
    [javac] C:\fls\tmp\src\com\maxware\fls\om\BaseAccPeer.java:109: The
method org.apache.turbine.om.ObjectKey
doInsert(org.apache.turbine.util.db.Criteria) declared in class
com.maxware.fls.om.BaseAccPeer cannot override the method of the same
signature declared in class org.apache.turbine.om.peer.BasePeer.  They must
have the same return type.
    [javac]     public static ObjectKey doInsert( Criteria criteria ) throws
Exception
    [javac]                             ^
    [javac] C:\fls\tmp\src\com\maxware\fls\om\BaseAccPeer.java:120: The
method org.apache.turbine.om.ObjectKey
doInsert(org.apache.turbine.util.db.Criteria,
org.apache.turbine.util.db.pool.DBConnection) declared in class
com.maxware.fls.om.BaseAccPeer cannot override the method of the same
signature declared in class org.apache.turbine.om.peer.BasePeer.  They must
have the same return type.
    [javac]     public static ObjectKey doInsert( Criteria criteria,
DBConnection dbCon )
    [javac]                             ^
    [javac] C:\fls\tmp\src\com\maxware\fls\om\BaseApc.java:27: Interface
com.maxware.fls.om.Retrievable of class com.maxware.fls.om.BaseApc not
found.


From: Alexis HAUMONT
To: turbine-user@jakarta.apache.org
Sent: Thursday, April 05, 2001 18:36
Subject: BigDecimal PK fields treated as StringKey by BasePeer


Hi all !

I'm joining the Turbine force after several home-made java web
applications..
seems like you've done a great job !

As We're just building our first app, we used the latest TDK and build
all our peer objects with Torque, everything  went great..
With several more Torque/Velocity-templates  we've build the basics of
our application with default Action/Screen/templates for each tables..

But I have one question related to the mapping between SQL Types and
Java types : why are my INTEGER SQL type mapped to Java 'int' ??
How do I handle NULL SQL values ??

I've found out that if I declare my field as NUMERIC in my xml-schema, the
mapping use BigDecimal which I definitely prefer.

But with all my fields declared as BigDecimals, i've encountered a bug
in BasePeer.doInsert(), which returned a StringKey Object for my NUMERIC PK.

I'm new to Turbine, so maybe I'm misunderstanding something, but by changing
this one line in BasePeer everything went great :


Index: BasePeer.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine/src/java/org/apache/turbine/om/peer/BasePeer
.java,v
retrieving revision 1.50
diff -u -r1.50 BasePeer.java
--- BasePeer.java 2001/04/05 04:46:46 1.50
+++ BasePeer.java 2001/04/05 16:12:24
@@ -718,7 +718,7 @@
             // before the insert.
             if (keyGen.isPriorToInsert())
             {
-                if ( pk.getType() instanceof Integer )
+                if ( pk.getType() instanceof Number )
                 {
                     id = new NumberKey( tableMap.getIdGenerator()
                         .getIdAsBigDecimal(dbCon.getConnection(), keyInfo)
);




Index: BasePeer.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine/src/java/org/apache/turbine/om/peer/BasePeer
.java,v
retrieving revision 1.50
diff -u -r1.50 BasePeer.java
--- BasePeer.java 2001/04/05 04:46:46 1.50
+++ BasePeer.java 2001/04/05 16:12:24
@@ -718,7 +718,7 @@
             // before the insert.
             if (keyGen.isPriorToInsert())
             {
-                if ( pk.getType() instanceof Integer )
+                if ( pk.getType() instanceof Number )
                 {
                     id = new NumberKey( tableMap.getIdGenerator()
                         .getIdAsBigDecimal(dbCon.getConnection(), keyInfo)
);

---------------------------------------------------------------------
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: BigDecimal PK fields treated as StringKey by BasePeer

Posted by John McNally <jm...@collab.net>.
patch applied. thanks.
john mcnally

Alexis HAUMONT wrote:
> 
> Hi all !
> 
> I'm joining the Turbine force after several home-made java web
> applications..
> seems like you've done a great job !
> 
> As We're just building our first app, we used the latest TDK and build
> all our peer objects with Torque, everything  went great..
> With several more Torque/Velocity-templates  we've build the basics of
> our application with default Action/Screen/templates for each tables..
> 
> But I have one question related to the mapping between SQL Types and
> Java types : why are my INTEGER SQL type mapped to Java 'int' ??
> How do I handle NULL SQL values ??
> 
> I've found out that if I declare my field as NUMERIC in my xml-schema, the
> mapping use BigDecimal which I definitely prefer.
> 
> But with all my fields declared as BigDecimals, i've encountered a bug
> in BasePeer.doInsert(), which returned a StringKey Object for my NUMERIC PK.
> 
> I'm new to Turbine, so maybe I'm misunderstanding something, but by changing
> this one line in BasePeer everything went great :
> 
> Index: BasePeer.java
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-turbine/src/java/org/apache/turbine/om/peer/BasePeer
> .java,v
> retrieving revision 1.50
> diff -u -r1.50 BasePeer.java
> --- BasePeer.java       2001/04/05 04:46:46     1.50
> +++ BasePeer.java       2001/04/05 16:12:24
> @@ -718,7 +718,7 @@
>              // before the insert.
>              if (keyGen.isPriorToInsert())
>              {
> -                if ( pk.getType() instanceof Integer )
> +                if ( pk.getType() instanceof Number )
>                  {
>                      id = new NumberKey( tableMap.getIdGenerator()
>                          .getIdAsBigDecimal(dbCon.getConnection(), keyInfo)
> );
> 
> Index: BasePeer.java
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-turbine/src/java/org/apache/turbine/om/peer/BasePeer
> .java,v
> retrieving revision 1.50
> diff -u -r1.50 BasePeer.java
> --- BasePeer.java       2001/04/05 04:46:46     1.50
> +++ BasePeer.java       2001/04/05 16:12:24
> @@ -718,7 +718,7 @@
>              // before the insert.
>              if (keyGen.isPriorToInsert())
>              {
> -                if ( pk.getType() instanceof Integer )
> +                if ( pk.getType() instanceof Number )
>                  {
>                      id = new NumberKey( tableMap.getIdGenerator()
>                          .getIdAsBigDecimal(dbCon.getConnection(), keyInfo)
> );
> 
> ---------------------------------------------------------------------
> 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