Yep... that'll do it in HSQLDB. Of course, if he's generating his
non-test database from Cayenne as well, he may not want to lose this
precision.
Something like this would allow you to generate HSQLDB-compliant sql
while still generating more precise SQL for your regular RDBMS:
for (Iterator entityIter = dataMap.getDbEntities().iterator();
entityIter.hasNext(); ) {
DbEntity entity = (DbEntity) entityIter.next();
for (Iterator attrIter = entity.getAttributes().iterator();
attrIter.hasNext(); ) {
DbAttribute attr = (DbAttribute) attrIter.next();
if (attr.getType() == java.sql.Types.DOUBLE) {
attr.setPrecision(0);
}
}
}
Probably, you can just clear the precision out of the modeler, though :)
On 11/3/06, Andrus Adamchik <andru..bjectstyle.org> wrote:
> I think Cris is right - try clearing the "length" field of the
> 'rechnungsBetrag' column in the Modeler.
>
> Andrus
>
>
>
> On Nov 3, 2006, at 9:59 AM, Christian Mittendorf wrote:
>
> > This is the db entity:
> >
> > <db-entity name="invoices" catalog="boni">
> > <db-attribute name="anum" type="VARCHAR" length="45"/>
> > <db-attribute name="belegNummer" type="BIGINT"
> > isMandatory="true" length="20"/>
> > <db-attribute name="cid" type="BIGINT" isMandatory="true"
> > length="20"/>
> > <db-attribute name="id" type="BIGINT" isPrimaryKey="true"
> > isMandatory="true" length="20"/>
> > <db-attribute name="mahnStufe" type="INTEGER"
> > isMandatory="true" length="11"/>
> > <db-attribute name="opNummer" type="VARCHAR"
> > isMandatory="true" length="45"/>
> > <db-attribute name="rechnungsBetrag" type="DOUBLE"
> > isMandatory="true" length="22"/>
> > <db-attribute name="rechnungsDatum" type="DATE"
> > isMandatory="true" length="10"/>
> > </db-entity>
> >
> > Christian
> >
> > Am 03.11.2006 um 15:13 schrieb Cris Daniluk:
> >
> >> Looks ilke the DOUBLE(22) is the problem.. HSQLDB doesn't support
> >> precision on a double. Can you include the DbEntity in the DataMap?
> >> the ObjEntity isn't very helpful.
> >>
> >> Cris
> >>
> >> On 11/3/06, Christian Mittendorf <christian.mittendor..reenet.de>
> >> wrote:
> >>>
> >>> Am 03.11.2006 um 00:01 schrieb Christian Mittendorf:
> >>>
> >>> > Thanks to all of your for hints!
> >>>
> >>> Ok, I'm now quite close to what I would like to accomplish. Except
> >>> for one Exception...
> >>>
> >>> 09:43:01,565 INFO [QueryLogger] *** error.
> >>> java.sql.SQLException: Unexpected token in statement [CREATE CACHED
> >>> TABLE invoices (anum VARCHAR(45) NULL, belegNummer BIGINT NOT NULL,
> >>> cid BIGINT NOT NULL, id BIGINT NOT NULL, mahnStufe INTEGER NOT NULL,
> >>> opNummer VARCHAR(45) NOT NULL, rechnungsBetrag DOUBLE(22]
> >>> at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
> >>> at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source)
> >>> at org.hsqldb.jdbc.jdbcStatement.execute(Unknown Source)
> >>> at org.objectstyle.cayenne.access.DbGenerator.safeExecute
> >>> (DbGenerator.java:399)
> >>> at org.objectstyle.cayenne.access.DbGenerator.runGenerator
> >>> (DbGenerator.java:339)
> >>> at de.freenet.cayenne.junit.DatabaseTestCase.setUpDataNodes
> >>> (DatabaseTestCase.java:66)
> >>> at de.freenet.cayenne.junit.DatabaseTestCase.setUp
> >>> (DatabaseTestCase.java:38)
> >>> at junit.framework.TestCase.runBare(TestCase.java:125)
> >>> at junit.framework.TestResult$1.protect(TestResult.java:106)
> >>> at junit.framework.TestResult.runProtected
> >>> (TestResult.java:124)
> >>> at junit.framework.TestResult.run(TestResult.java:109)
> >>> at junit.framework.TestCase.run(TestCase.java:118)
> >>> at junit.framework.TestSuite.runTest(TestSuite.java:208)
> >>> at junit.framework.TestSuite.run(TestSuite.java:203)
> >>> at
> >>> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run
> >>> (JUnit3TestReference.java:128)
> >>> at org.eclipse.jdt.internal.junit.runner.TestExecution.run
> >>> (TestExecution.java:38)
> >>> at
> >>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
> >>> (RemoteTestRunner.java:460)
> >>> at
> >>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
> >>> (RemoteTestRunner.java:673)
> >>> at
> >>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run
> >>> (RemoteTestRunner.java:386)
> >>> at
> >>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main
> >>> (RemoteTestRunner.java:196)
> >>>
> >>> I've validated the cayenne project with the modeler and everything
> >>> seems to be fine. In the xml the table looks like this:
> >>>
> >>> <obj-entity name="Invoices"
> >>> className="de.freenet.cayenne.bonitaet.Invoices"
> >>> dbEntityName="invoices">
> >>> <obj-attribute name="anum" type="java.lang.String" db-
> >>> attribute-
> >>> path="anum"/>
> >>> <obj-attribute name="belegNummer" type="java.lang.Long"
> >>> db-attribute-
> >>> path="belegNummer"/>
> >>> <obj-attribute name="cid" type="java.lang.Long" db-
> >>> attribute-
> >>> path="cid"/>
> >>> <obj-attribute name="mahnStufe" type="java.lang.Integer" db-
> >>> attribute-path="mahnStufe"/>
> >>> <obj-attribute name="opNummer" type="java.lang.String" db-
> >>> attribute-
> >>> path="opNummer"/>
> >>> <obj-attribute name="rechnungsBetrag"
> >>> type="java.lang.Double" db-
> >>> attribute-path="rechnungsBetrag"/>
> >>> <obj-attribute name="rechnungsDatum"
> >>> type="java.util.Date" db-
> >>> attribute-path="rechnungsDatum"/>
> >>> </obj-entity>
> >>>
> >>> Any idea anybody?
> >>>
> >>> Christian
> >>>
> >>>
> >
> >
>
>
This archive was generated by hypermail 2.0.0 : Fri Nov 03 2006 - 18:58:10 EST