Dear Giovanni,
I'm trying to map types returned by the S/P to custom types, but I can't get it to work.
I need to map a result set column of type NUMBER(38) to a java Long as opposed to BigDecimal.
From what I understood from the documentation, I should be writing the following:
but the above code does not seem to work: I still get BigDecimals as opposed to longs.
I'm sure I'm using it correctly, can you please tell me what is wrong?
Kind regards,
Xserty
PS: I don't want the developer to set spwrapper.addTypeMap(...), I'd like to do it via ant.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, please read the following line
> I'm sure I'm using it correctly, can you please tell me what is wrong?
as
> I'm sure I'm *NOT* using it correctly, can you please tell me what is wrong?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Supposing you have
create or replace function bigintkey
return number is
Result number(38,0);
begin
Result:=12345678901234567890123456789012345678;
return(Result);
end bigintkey;
Here is the ant file generated by nebeans wizard
<override paramname='ret' sqltype='BIGINT'/> is the line you was looking for.
By the way a java long is too short to hold 38 digit! you will get a runtime exception. I see BigDecimal in your future.
The type mappingg is an quite strange functionality you can use to map sql objects to java objecs implementing the SQLData interface. Look at StructTestObject into net.sourceforge.spwrapper.test.oracle for an example.
Hi Giovanni, I figured out how it worked in the end... but thanks for your reply anyways.
Regarding the BigDecimal to Long conversion, that was just a temporary measure.
We are already back to BigDecimals now!
All the best,
Xserty
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear Giovanni,
I'm trying to map types returned by the S/P to custom types, but I can't get it to work.
I need to map a result set column of type NUMBER(38) to a java Long as opposed to BigDecimal.
From what I understood from the documentation, I should be writing the following:
<spwrapper procedurename="LIST_ALL_USERS" connectionstring="${connection.string}" password="${password}" username="${username}" javapackage="${spw.dest.package}" targetdirectory="${dest.src.dir}">
<override paramname="P_STATUSUSER" sqltype="BIGINT" />
<typeMapping sqltype="NUMBER" javatype="java.lang.Long" />
<typeMapping sqltype="DECIMAL" javatype="java.lang.Long" />
</spwrapper>
but the above code does not seem to work: I still get BigDecimals as opposed to longs.
I'm sure I'm using it correctly, can you please tell me what is wrong?
Kind regards,
Xserty
PS: I don't want the developer to set spwrapper.addTypeMap(...), I'd like to do it via ant.
Sorry, please read the following line
> I'm sure I'm using it correctly, can you please tell me what is wrong?
as
> I'm sure I'm *NOT* using it correctly, can you please tell me what is wrong?
Hello, this is what you should do:
Supposing you have
create or replace function bigintkey
return number is
Result number(38,0);
begin
Result:=12345678901234567890123456789012345678;
return(Result);
end bigintkey;
Here is the ant file generated by nebeans wizard
<override paramname='ret' sqltype='BIGINT'/> is the line you was looking for.
By the way a java long is too short to hold 38 digit! you will get a runtime exception. I see BigDecimal in your future.
The type mappingg is an quite strange functionality you can use to map sql objects to java objecs implementing the SQLData interface. Look at StructTestObject into net.sourceforge.spwrapper.test.oracle for an example.
<?xml version="1.0" encoding="UTF-8"?>
<project name="performTests" default="all" basedir="..\..\">
<!-- 0 basedir
1 connection string
2 username
3 password
4 classpath
5 package name
6 procedure name
7 target directory
8 formatted overrides
9 custom types mapping
10 classname -->
<echo message="building Bigkey"></echo>
<property name="build-test" value="${basedir}" />
<path id="compile-path" path="..\..\..\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14_g.jar;..\..\..\gio\work\distribution\spwrapper.jar;" />
<target name="all">
<!-- 5 -->
<taskdef name="spwrapper"
classname="net.sourceforge.spwrapper.ant.SPWrapperTask"
classpathref="compile-path" />
<!-- 6 -->
<spwrapper javaclassname="Bigkey"
connectionstring="jdbc:oracle:thin:@localhost:1521:orcl"
password="yyyyy"
username="xxxxxx"
javapackage="testapplication"
procedurename="BIGINTKEY"
targetdirectory="src">
<override paramname='ret' sqltype='BIGINT'/>
</spwrapper>
</target>
</project>
Hi Giovanni, I figured out how it worked in the end... but thanks for your reply anyways.
Regarding the BigDecimal to Long conversion, that was just a temporary measure.
We are already back to BigDecimals now!
All the best,
Xserty