Please supply diff's of the form given by cvs diff -u
john mcnally
Patrick Tonidandel wrote:
>
> Dear Gentlemen,
>
> some Days ago I tried to contact you regarding a problem with Village.
> I am speaking about the case if a column of my database contains a native
> value like
> int, short, byte, float or double that is NULL.
>
> In this special case the Peers-classes generated with Torque return 0
> (zero).
>
> This was not correct enough for my application, so I asked how to modify the
> different
> layers.
>
> In the meantime i made following modifications to village-1.5.3-dev.jar
> and torque-1.0.jar. I send you the modified files as attachment and in the
> following lines
> i try to describe you briefly what i made:
>
> IMPORTANT !
> Following modifications where made not only to the int-nativetype but to all
> other native types
> (short, long, byte, float double) as well. Now i mention just the
> modifications to 'int' for simplicity.
>
> - (Project Village) Class Value was altered to contain a new method called
> Value.asIntegerObj();
>
> public Integer asIntegerObj() throws DataSetException
> {
> try
> {
> if (isNull())
> return null;
> else if (isInt())
> return ((Integer) valueObject);
> else if (isString() || isDouble() || isFloat() || isBigDecimal()
> ||
> isLong() || isShort() || isByte() )
> return new Integer (asString());
> else
> return null;
> }
> catch (Exception e)
> {
> throw new DataSetException("Illegal conversion: " +
> e.toString());
> }
> }
>
> - (Project Torque) Torque uses the new created village-1.5.3-devModified.jar
> .
>
> TypeMap.java has to be modified so that the new "asIntegerObj()" method
> will be used in the
> generation:
>
> public static final String INTEGER_VILLAGE_METHOD = "asIntegerObj()";
>
> The Hashtable jdbcToJavaNativeMap in TypeMap.java now is mapping
> Object-types instead of native-types.
>
> public static final String INTEGER_NATIVE_TYPE = "Integer";
>
> Column.java has to be modified like follows:
> - The method getJavaNative() should map objecttype Integer to
>Numberkey.
> - The method getVillageMethod has been modified also.
>
> Column.java ---------------------------------------- > code
>
> public String getJavaNative()
> {
> String jtype = TypeMap.getJavaNative(torqueType);
> if ( isPrimaryKey() || isForeignKey() )
> {
> if ( jtype.equals("String") )
> {
> jtype = "StringKey";
> }
> else if ( jtype.equals("Date") )
> {
> jtype = "DateKey";
> }
> else if ( jtype.equals("short")
> || jtype.equals("int")
> || jtype.equals("long")
> || jtype.equals("BigDecimal")
> || jtype.equals("byte")
> || jtype.equals("float")
> || jtype.equals("double")
> || jtype.equals("Short")
> || jtype.equals("Integer")
> || jtype.equals("Long")
> || jtype.equals("Byte")
> || jtype.equals("Float")
> || jtype.equals("Double") )
> {
> jtype = "NumberKey";
> }
>
> }
>
> return jtype;
> }
>
> public String getVillageMethod()
> {
> String vmethod = TypeMap.getVillageMethod(torqueType);
> String jtype = TypeMap.getJavaNative(torqueType);
> if ( isPrimaryKey() || isForeignKey() )
> {
> if ( jtype.equals("short")
> || jtype.equals("int")
> || jtype.equals("long")
> || jtype.equals("byte")
> || jtype.equals("float")
> || jtype.equals("double")
> || jtype.equals("Short")
> || jtype.equals("Integer")
> || jtype.equals("Long")
> || jtype.equals("Byte")
> || jtype.equals("Float")
> || jtype.equals("Double") )
> {
> vmethod = "asBigDecimal()";
> }
> }
> return vmethod;
> }
> Column.java ----------------------------------------------- < code
>
> - Now we can generate the jar file of Torque and include it in our projects
> and generate the new
> Peer-Classes. The get- and set-Methods now will deal with Object-datatypes
> instead of native- datatypes.
>
> I hope that this information can be usefull for a patch.
>
> Regards
> Patrick Tonidandel
>
> ------------------------------------------------------------------------
> Name: Column.java
> Column.java Type: JavaScript Program (application/x-javascript)
> Encoding: quoted-printable
>
> Name: Value.java
> Value.java Type: JavaScript Program (application/x-javascript)
> Encoding: quoted-printable
>
> Name: TypeMap.java
> TypeMap.java Type: JavaScript Program (application/x-javascript)
> Encoding: quoted-printable
>
> ------------------------------------------------------------------------
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>