Hallo Cayenne Community,
I like your project! But I can't get a simple Example
to run. I used the newest hsqldb and the newest
cayenne.jar (I tried also your hsqldb-1.8.0.2.jar from
the modeler).
Now I do the following
1. "Easy creating a SimplePerson object with the
modeler" (with name=VARCHAR and myint=INTEGER)
2. calling context.newObject
3. and commitChanges()
The result of the last step is that cayenne queries an
INSERT with the correct Id
and a NULL name?? I can't figure out whats wrong.
The map.xml:
<?xml version="1.0" encoding="utf-8"?>
<data-map project-version="1.1">
<property name="defaultPackage" value="test"/>
<property name="defaultSchema" value="PUBLIC"/>
<db-entity name="SimplePerson" schema="PUBLIC">
<db-attribute name="ID" type="INTEGER"
isPrimaryKey="true" isMandatory="true"/>
<db-attribute name="myint" type="INTEGER"/>
<db-attribute name="name" type="VARCHAR"
length="255"/>
</db-entity>
<obj-entity name="SimplePerson"
className="test.SimplePerson"
dbEntityName="SimplePerson">
<obj-attribute name="myint" type="java.lang.Integer"
db-attribute-path="myint"/>
<obj-attribute name="name" type="java.lang.String"
db-attribute-path="name"/>
</obj-entity>
</data-map>
Here is the driver.xml:
<?xml version="1.0" encoding="utf-8"?>
<driver project-version="1.1"
class="org.hsqldb.jdbcDriver">
<url value="jdbc:hsqldb:file:I:\secCayenne"/>
<connectionPool min="1" max="1" />
<login userName="sa"/>
</driver>
And thats the cayenne.xml
<?xml version="1.0" encoding="utf-8"?>
<domains project-version="1.1">
<domain name="SimpleTest">
<map name="SimpleTestMap"
location="SimpleTestMap.map.xml"/>
<node name="SimpleTestNode"
datasource="SimpleTestNode.driver.xml"
factory="org.objectstyle.cayenne.conf.DriverDataSourceFactory">
<map-ref name="SimpleTestMap"/>
</node>
</domain>
</domains>
After creating the db schema and generating the
classes the program:
DataContext context = DataContext.createDataContext();
SimplePerson p =
(SimplePerson)context.newObject(SimplePerson.class);
p.setMyint(new Integer(22));
String lastName = "testName";
p.setName(lastName);
System.out.println(""+context.hasChanges());
context.commitChanges();
prints out the following:
INFO QueryLogger: Created connection pool:
jdbc:hsqldb:file:I:\secCayenne
Driver class: org.hsqldb.jdbcDriver
Min. connections in the pool: 1
Max. connections in the pool: 1
true
INFO QueryLogger: Opening connection:
jdbc:hsqldb:file:I:\secCayenne
Login: sa
Password: *******
INFO QueryLogger: +++ Connecting: SUCCESS.
INFO QueryLogger: Detected and installed adapter:
org.objectstyle.cayenne.dba.hsqldb.HSQLDBAdapter
INFO QueryLogger: --- will run 2 queries.
INFO QueryLogger: --- transaction started.
INFO QueryLogger: SELECT NEXT_ID FROM AUTO_PK_SUPPORT
WHERE TABLE_NAME = 'SimplePerson'
INFO QueryLogger: === returned 1 row. - took 31 ms.
INFO QueryLogger: UPDATE AUTO_PK_SUPPORT SET NEXT_ID
= NEXT_ID + 20 WHERE TABLE_NAME = 'SimplePerson'
INFO QueryLogger: === updated 1 row.
INFO QueryLogger: --- will run 1 query.
INFO QueryLogger: INSERT INTO PUBLIC.SimplePerson
(ID, myint, name) VALUES (?, ?, ?)
INFO QueryLogger: [bind: 240, NULL, NULL]
<----- NULL, NULL is wrong!!??
INFO QueryLogger: === updated 1 row.
...
Again: Where is my mistake?
Thank you, Peter Karich!
PS:
May be this helps you to understand what happend (I
debuggend through cayenne):
1. in line 120, class DataDomainInsertBucket, method
appendQueriesInternal():
after "if (isMasterDbEntity)
{createPermIdsForObjEntity(entity, objects); ..."
all is okay: objects contains one onbject:
SimplePersons(name="testName", myint=22)
2. BUT in DataDomainFlushAction.runQueries the method:
lastNode.performQueries(queries.subList(rangeStart,
len), observer);
will create a Collection named queries (size==1) in
DataNode and queryRunner.runQuery(connection,
nextQuery);
3. results: "INFO QueryLogger: [bind: 240, NULL,
NULL]"
___________________________________________________________
Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
This archive was generated by hypermail 2.0.0 : Thu Aug 03 2006 - 11:26:12 EDT