Discussion:
[Middlegen-user] error with new BigDecimal(BigDecimal)
K C Lau
2002-11-26 01:34:02 UTC
Permalink
I tried the samples in Middlegen-2.0-b1 on Windows 2000, JBoss 3.0.0 and
Sun jdk 1.3.1_04-b02.
It ran fine with hsqldb. Thanks for this impressive product.

I then tried the samples with an Oracle 8.1.7 database with already
existing tables.

Compilation fails on many generated action classes during Compile-web with:

compile-web:
Overriding previous definition of reference to compile.class.path
[javac] Compiling 1054 source files to
C:\middlegen-2.0-b1\samples\build\classes
[javac]
C:\middlegen-2.0-b1\samples\build\gen-src\airline\web\struts\DeleteAmTJobAction.java:60:
cannot resolve symbol
[javac] symbol : constructor BigDecimal (java.math.BigDecimal)
[javac] location: class java.math.BigDecimal
[javac] java.math.BigDecimal amTJob_PK = new
java.math.BigDecimal(jobId);

The generated source is typically:

public ActionForward perform(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response
)
throws IOException, ServletException {

// Create a primary key to look up
java.math.BigDecimal jobId = new
java.math.BigDecimal(getParameter(request, "jobId"));

java.math.BigDecimal amTJob_PK = new java.math.BigDecimal(jobId);

job_id is defined as integer not null in the AmTJob table.

This problem does not seem to have been reported.

BTW, I could not download the CVS source using WinCVS as per the
instruction on the download page:

cvs -d:pserver:***@cvs.middlegen.sourceforge.net:/cvsroot/middlegen
login

Am I missing something here? Which modulename should I use if I could
eventually login?

Thanks,
KC Lau.
Jens Fischer
2002-11-26 05:41:01 UTC
Permalink
Hallo K,
Post by K C Lau
I tried the samples in Middlegen-2.0-b1 on Windows 2000, JBoss 3.0.0 and
Sun jdk 1.3.1_04-b02.
It ran fine with hsqldb. Thanks for this impressive product.
I then tried the samples with an Oracle 8.1.7 database with already
existing tables.
Overriding previous definition of reference to compile.class.path
[javac] Compiling 1054 source files to
C:\middlegen-2.0-b1\samples\build\classes
[javac]
cannot resolve symbol
[javac] symbol : constructor BigDecimal (java.math.BigDecimal)
[javac] location: class java.math.BigDecimal
[javac] java.math.BigDecimal amTJob_PK = new
java.math.BigDecimal(jobId);
[...]

After the first Middlegen run you have to edit the
middlegen-prefs.[xml|properties] and manually replace every
java.lang.BigDecimal with java.lang.Integer. Oh, and if you are
already at this, take care of the java.sql.Timestamp and all the
primitive data types if you like to.
Post by K C Lau
Thanks,
KC Lau.
--
MfG,
Jens
K C Lau
2002-11-29 00:38:03 UTC
Permalink
Hi All,

I finally got it working on Oracle 8 and JBoss 3.0.4 with Tomcat 4.1.12, at
least on a small sample of my tables, by patching the CVS of 02/11/26.

I wonder if anybody has similar experience with Oracle tables using
Middlegen 2.0b1 or the latest CVS on other J2EE App Servers or databases.

The changes I made include:
1. edit delete-action.vm, edit-action.vm and view-action.vm in
middlegen\plugins to handle the case of single non-primitive primary key
This fixes the new BigDecimal(BigDecimal) compile error during
compile-web.

2. foce middlegen.javax.Sql2Java getPreferredJavaType to return primitive
long or double for Oracle's NUMBER data types.
Otherwise JBoss will fail with
org.jboss.ejb.plugins.cmp.ejbql.ParseException on deployment. In fact,
JBoss will also fail in a similar manner if I use BigDecimal for my MS Sql
tables.
This change has a side-effect for MS Sql tables (and others) by
using double instead of java.lang.Double. But I guess that should be ok.

BTW, with Oracle, I think the main issue is that Oracle using NUMBER for
the ANSI INTEGER datatype which internally is represented by 128-bit
NUMBER(38). This may make it a hard decision to use long or even int. Only
the application developer will know. So it would be another reason to allow
user-definable defaults for this and other data types, a feature already
requested on the list.

Please feel free to contact me if you want the modified java and vm files.

Cheers,
KC.

ps.
Post by Aslak Hellesoy
And if you're a dumb user, you can also do this in the GUI. Just select the
columns you want to change and set the desired type in the combo. I wonder
why nobody sees this...
Thanks and no thanks. I'll have to find one who is more stupid than me to
go through all the tables.
Post by Aslak Hellesoy
The reason why this happened is probably due to Hsqldb and PostgreSQL
reporting different JDBC types for some columns, and the old prefs file
(generated in hsqldb mode) doesn't "fit" the one generated in PostgreSQL
mode. You could try deleting (moving away) the prefs file before generating
with Oracle.
I did, but that did not help.
Post by Aslak Hellesoy
Aslak
-----Original Message-----
Fischer
Sent: 26. november 2002 08:40
Subject: Re: [Middlegen-user] error with new BigDecimal(BigDecimal)
Hallo K,
Post by K C Lau
I tried the samples in Middlegen-2.0-b1 on Windows 2000, JBoss
3.0.0 and
Post by K C Lau
Sun jdk 1.3.1_04-b02.
It ran fine with hsqldb. Thanks for this impressive product.
I then tried the samples with an Oracle 8.1.7 database with already
existing tables.
Compilation fails on many generated action classes during
Overriding previous definition of reference to compile.class.path
[javac] Compiling 1054 source files to
C:\middlegen-2.0-b1\samples\build\classes
[javac]
C:\middlegen-2.0-b1\samples\build\gen-src\airline\web\struts\Delet
Post by K C Lau
cannot resolve symbol
[javac] symbol : constructor BigDecimal (java.math.BigDecimal)
[javac] location: class java.math.BigDecimal
[javac] java.math.BigDecimal amTJob_PK = new
java.math.BigDecimal(jobId);
[...]
After the first Middlegen run you have to edit the
middlegen-prefs.[xml|properties] and manually replace every
java.lang.BigDecimal with java.lang.Integer. Oh, and if you are
already at this, take care of the java.sql.Timestamp and all the
primitive data types if you like to.
It appears that to deploy on JBoss 3.0.4, I have to do the following:
1. define the data type for keys in cmp20.tables to use a class instead of
a primitive, e.g. Integer
2. define the data type for keys and others in myjsp.tables, struts.tables
and sunjdo10.tables to use a primitive, eg. int
3. non-key columns in cmp20.tables can use a class or a primitive.
It quickly becomes tedious and error-prone.
Post by Aslak Hellesoy
Post by K C Lau
Thanks,
KC Lau.
--
MfG,
Jens
Aslak Hellesoy
2002-11-26 09:09:03 UTC
Permalink
And if you're a dumb user, you can also do this in the GUI. Just select the
columns you want to change and set the desired type in the combo. I wonder
why nobody sees this...

The reason why this happened is probably due to Hsqldb and PostgreSQL
reporting different JDBC types for some columns, and the old prefs file
(generated in hsqldb mode) doesn't "fit" the one generated in PostgreSQL
mode. You could try deleting (moving away) the prefs file before generating
with Oracle.

Aslak
-----Original Message-----
Fischer
Sent: 26. november 2002 08:40
Subject: Re: [Middlegen-user] error with new BigDecimal(BigDecimal)
Hallo K,
Post by K C Lau
I tried the samples in Middlegen-2.0-b1 on Windows 2000, JBoss
3.0.0 and
Post by K C Lau
Sun jdk 1.3.1_04-b02.
It ran fine with hsqldb. Thanks for this impressive product.
I then tried the samples with an Oracle 8.1.7 database with already
existing tables.
Compilation fails on many generated action classes during
Overriding previous definition of reference to compile.class.path
[javac] Compiling 1054 source files to
C:\middlegen-2.0-b1\samples\build\classes
[javac]
C:\middlegen-2.0-b1\samples\build\gen-src\airline\web\struts\Delet
Post by K C Lau
cannot resolve symbol
[javac] symbol : constructor BigDecimal (java.math.BigDecimal)
[javac] location: class java.math.BigDecimal
[javac] java.math.BigDecimal amTJob_PK = new
java.math.BigDecimal(jobId);
[...]
After the first Middlegen run you have to edit the
middlegen-prefs.[xml|properties] and manually replace every
java.lang.BigDecimal with java.lang.Integer. Oh, and if you are
already at this, take care of the java.sql.Timestamp and all the
primitive data types if you like to.
Post by K C Lau
Thanks,
KC Lau.
--
MfG,
Jens
-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T
handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Aslak Hellesoy
2002-11-26 09:16:02 UTC
Permalink
The module name is middlegen

---------

BTW, I could not download the CVS source using WinCVS as per the instruction
on the download page:

cvs -d:pserver:***@cvs.middlegen.sourceforge.net:/cvsroot/middlegen
login

Am I missing something here? Which modulename should I use if I could
eventually login?

Thanks,
KC Lau.
Loading...