Hah! Success!
It seemed that I did not have a primary key field defined. I define that,
and I have just had a successful commit.
*) newObject
*) assign
*) commit
works.
Does Cayenne provide a SQL Data type helper? Something that helps
Cayenne guess SQL data types for given value types? Or must I
implement my own?
Regards,
Kevin
On 12 Dec 2011 at 20:21, Kevin Meyer - KMZ wrote:
> Ah! Next problem.
>
> Having found the datanode with:
> DataDomain dataDomain =
> runtime.getInjector().getInstance(DataDomain.class);
> DataNode dataNode = dataDomain.getNode("datanode");
> ...
> dataNode.addDataMap(dataMap);
>
>
> I now get the following in the log:
> 20:15:15,961 [CommonsJdbcEventLogger main INFO ] +++ Connecting:
> SUCCESS.
> 20:15:16,071 [CommonsJdbcEventLogger main INFO ] Detected and
> installed adapter: org.apache.cayenne.dba.hsqldb.HSQLDBAdapter
> 20:15:16,075 [CommonsJdbcEventLogger main INFO ] --- transaction
> started.
> 20:15:16,123 [CreateIfNoSchemaStrategy main INFO ] No schema
> detected, will create mapped tables
> 20:15:16,130 [CommonsJdbcEventLogger main INFO ] CREATE CACHED TABLE
> SimpleClassA (number INTEGER NULL, persistent INTEGER NULL)
> 20:15:16,253 [CommonsJdbcEventLogger main INFO ] CREATE TABLE
> AUTO_PK_SUPPORT ( TABLE_NAME CHAR(100) NOT NULL, NEXT_ID BIGINT NOT NULL,
> PRIMARY KEY(TABLE_NAME))
> 20:15:16,254 [CommonsJdbcEventLogger main INFO ] DELETE FROM
> AUTO_PK_SUPPORT WHERE TABLE_NAME IN ()
> 20:15:16,258 [CommonsJdbcEventLogger main INFO ] *** error.
> java.sql.SQLException: Unexpected token: ) in statement [DELETE FROM
> AUTO_PK_SUPPORT WHERE TABLE_NAME IN ()]
> 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.apache.cayenne.access.DbGenerator.safeExecute(DbGenerator.java:377)
> at
> org.apache.cayenne.access.DbGenerator.runGenerator(DbGenerator.java:355)
> at
> org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy.generate(CreateIfNoSchemaStrategy.java:79)
> ....
> ....
> 20:15:16,287 [CommonsJdbcEventLogger main INFO ] INSERT INTO
> SimpleClassA (number, persistent) VALUES (?, ?)
> 20:15:16,290 [CommonsJdbcEventLogger main INFO ] [bind:
> 1->number:NULL, 2->persistent:NULL]
> 20:15:16,292 [CommonsJdbcEventLogger main INFO ] === updated 1 row.
> 20:17:32,778 [CommonsJdbcEventLogger main INFO ] --- transaction
> started.
> 20:17:32,779 [CommonsJdbcEventLogger main INFO ] INSERT INTO
> SimpleClassA (number, persistent) VALUES (?, ?)
> 20:17:32,779 [CommonsJdbcEventLogger main INFO ] [bind:
> 1->number:NULL, 2->persistent:NULL]
> 20:17:32,780 [CommonsJdbcEventLogger main INFO ] === updated 1 row.
> 20:17:32,780 [CommonsJdbcEventLogger main INFO ] [bind:
> 1->number:NULL, 2->persistent:NULL]
> 20:17:32,780 [CommonsJdbcEventLogger main INFO ] === updated 1 row.
>
>
> Followed by "Temporary ID hasn't been replaced on commit: "
>
> Any hints?
>
>
>
> On 12 Dec 2011 at 12:02, Mike Kienenberger wrote:
>
> > How are you creating a DataNode and what are you doing to assign DataMaps
> > to it?
> >
> > On Mon, Dec 12, 2011 at 11:52 AM, Kevin Meyer - KMZ <[email protected]> wrote:
> > > Ok, thanks, I call
> > > objAttribute.setDbAttributePath(id);
> > > and I am now back to my previous problem, where
> > > DataNode node =
> > > parent.getDomain().lookupDataNode(entity.getDataMap());
> > > has node == null in DataDomainInsertBucket#createPermIds.
> > >
> > > Any hints?
> > >
> > > On 12 Dec 2011 at 11:13, Mike Kienenberger wrote:
> > >
> > >> You may not need the prefix, but you at least need this much:
> > >>
> > >> // dot-separated path that starts in the root DbEntity
> > >> that maps to this attribute's ObjEntity and spans zero or more
> > >> relationships, always ending in a DbAttribute name.
> > >> objAttribute.setDbAttributePath(id);
> > >>
> > >> On Mon, Dec 12, 2011 at 11:10 AM, Kevin Meyer - KMZ <[email protected]>
> > >> wrote:
> > >> > Sorry, you guys are confusing me.
> > >> >
> > >> > I have a datamap (called "isis_map"), to which I have added a DbEntity
> > >> > (named after my class, "simpleclass") and a ObjEntity (with same
> > >> > name).
> > >> >
> > >> > The "id" I refer to is the name of a property of my class (called
> > >> > "number"). The class has methods setNumber and getNumber.
> > >> >
> > >> > That's the id ("number") that I assigned to DbAttribute and
> > >> > ObjAttribute.
> > >> >
> > >> > What is the prefix you refer to?
> > >> >
> > >> > regards,
> > >> > Kevin
> > >> >
> > >> > On 12 Dec 2011 at 9:20, John Huss wrote:
> > >> >
> > >> >> Yes, you need to link the Obj* things to the Db* things by name, both
> > >> >> the
> > >> >> entities and the attributes.
> > >> >>
> > >> >> On Mon, Dec 12, 2011 at 9:03 AM, Mike Kienenberger
> > >> >> <[email protected]>wrote:
> > >> >>
> > >> >> > I can't remember the exact details, but you might need (prefix +
> > >> >> > "." +
> > >> >> > id) instead of (id)
> > >> >> >
> > >> >> > On Mon, Dec 12, 2011 at 2:50 AM, Kevin Meyer - KMZ <[email protected]>
> > >> >> > wrote:
> > >> >> > > DbAttribute dbAttribute = new DbAttribute(id,
> > >> >> > java.sql.Types.INTEGER, dbEntity);
> > >> >> > > dbEntity.addAttribute(dbAttribute);
> > >> >> >
> > >> >> > + // dot-separated path that starts in the root
> > >> >> > DbEntity
> > >> >> > that maps to this attribute's ObjEntity and spans zero or more
> > >> >> > relationships, always ending in a DbAttribute name.
> > >> >> > + objAttribute.setDbAttributePath(id);
> > >> >> >
> > >> >> > >
> > >> >> > > ObjAttribute objAttribute = new ObjAttribute(id, type,
> > >> >> > objEntity);
> > >> >> >
> > >> >>
> > >> >
> > >> >
> > >> > --
> > >> > Kevin Meyer, PhD, Pr.Sci.Nat
> > >> > KMZ P.O. Box 9822, Sharon Park, South Africa.
> > >> > Tel: +27 11 363 2001 Cell: +27 83 346 3045
> > >> >
> > >> >
> > >
> > >
> > > --
> > > Kevin Meyer, PhD, Pr.Sci.Nat
> > > KMZ P.O. Box 9822, Sharon Park, South Africa.
> > > Tel: +27 11 363 2001 Cell: +27 83 346 3045
> > >
> > >
>
>
> --
> Kevin Meyer, PhD, Pr.Sci.Nat
> KMZ P.O. Box 9822, Sharon Park, South Africa.
> Tel: +27 11 363 2001 Cell: +27 83 346 3045
>
>
--
Kevin Meyer, PhD, Pr.Sci.Nat
KMZ P.O. Box 9822, Sharon Park, South Africa.
Tel: +27 11 363 2001 Cell: +27 83 346 3045