Hi Jan --
I didn't look closely at your example (busy! busy! eek!) but I believe
I know the problem. You have a nullable integer value somewhere.
Torque ALWAYS provides a default value, nullable or not. In this case
the value is "", which somehow gets turned into the result you're
seeing. I see this so much I have an XSLT script for fixups, it is
attached, hope it is some use. Also, if you want to improve the script
that would be great as I'm pretty much an idiot about XSLT!
Regards,
Gary
p.s. There's a section in the script that changes *BINARY to
LONGVARCHAR; my particular application has no true binary fields but
uses *BLOB types to avoid the string-specific rules in *TEXT.
[2003-11-26 17:53 +0100] Jan Krabbenbos ([EMAIL PROTECTED]) wrote:
> Hi
>
> I have a MySQL database which I generated the schema from. I changed the name
> into genDB-schema.xml, added the name and defaultIdMethod in the top of the
> schema, see the snippet below. Now I generate the object model with 'ant -f
> build-properties.xml om' and than try compiling it. For the given table below
> it comes with the following error message
>
> [javac]
> /home/jan/jbproject/MetaVis/src/java/com/intellisource/intellivis/metavis/BaseKlantendata.java:44:
>
> illegal start of expression
> [javac] private long kdvolgnr = ;
>
> If I add a default value of e.g. 0, it compiles. What have I done wrong? Did I
> miss something?
>
> <database
> name="genDB"
> defaultIdMethod="none">
> :
> :
> <table name="klantendata">
> <column default="0" name="klantdataSet" primaryKey="true"
> required="true" type="BIGINT"/>
> <column default="" name="kdVolgnr" primaryKey="true"
> required="true" type="BIGINT"/>
> <column default="" name="kdKey" required="true" size="50"
> type="VARCHAR"/>
> <column default="" name="kdValue" required="true" size="100"
> type="VARCHAR"/>
> <column default="" name="klantdataStamp" type="TIMESTAMP"/>
> </table>
> :
> :
> </database>
> --
> Met vriendelijke groet,
>
> Jan Krabbenbos
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> <?xml version="1.0"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"
doctype-system="http://db.apache.org/torque/dtd/database_3_1.dtd"
indent="yes" />
<xsl:template match="/">
<xsl:comment>Post-processed by torque-schema.xsl</xsl:comment>
<xsl:apply-templates/>
</xsl:template>
<!--
Supress empty boolean attributes
-->
<xsl:template match='@primaryKey[string(.)="false"]'/>
<xsl:template match='@autoIncrement[string(.)="false"]'/>
<xsl:template match='@inheritance[string(.)="false"]'/>
<!--
All fields which Torque translates as BINARY or VARBINARY are in
fact text values, semantically speaking. Cause Torque to treat
them as text by changing the field type to LONGVARCHAR.
-->
<xsl:template match='@type[string(.)="VARBINARY"]'>
<xsl:attribute name="type">LONGVARCHAR</xsl:attribute>
</xsl:template>
<xsl:template match='@type[string(.)="BINARY"]'>
<xsl:attribute name="type">LONGVARCHAR</xsl:attribute>
</xsl:template>
<!--
An INTEGER value which may not be null should have a default of 0.
In certain cases which I haven't been able to pin down yet, Torque
makes the default "", the empty string. This is the blanket
solution: set the default to "0" always if the field is
"required".
-->
<xsl:template match='[EMAIL PROTECTED]"INTEGER" and @required="true"]'>
<xsl:copy>
<xsl:attribute name="default">0</xsl:attribute>
<xsl:for-each select='@*[not(name(.)="default")]'>
<xsl:apply-templates select="."/>
</xsl:for-each>
</xsl:copy>
</xsl:template>
<!--
If a column is not required, make sure there's no default value.
Torque ALWAYS puts in a default value, dammit.
Any value which may be null must be represented by
a Java object, or there's no way to know it was null. Currently
all database fields are either strings or integers; in Java
the strings are automatically objects, but integer values
must be explicitly forced into Java objects.
-->
<xsl:template match='column[not(@required="true")]'>
<xsl:copy>
<xsl:for-each select='@*[not(name(.)="default") and not(name(.)="required")]'>
<xsl:apply-templates select="."/>
</xsl:for-each>
<xsl:if test='@type="INTEGER"'>
<xsl:attribute name="javaType">object</xsl:attribute>
</xsl:if>
</xsl:copy>
</xsl:template>
<!--
This is a simple identity function, insuring that anything we
don't match above still makes it into the document.
-->
<xsl:template match="@*|*|processing-instruction()|comment()"
priority="-2" >
<xsl:copy>
<xsl:apply-templates
select="*|@*|text()|processing-instruction()|comment()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]