Hello,
one of my relationships is not set and I can not find an explanation.
I fetch two objects from shared data context and create local copies.
MapObjectType mot =
persistenceService.findMapObjectType(MapObjectTypeEnum.STREET);
MapObjectType localMot = (MapObjectType)
dataContext.localObject(mot.getObjectId(), mot);
Town town = persistenceService.findTownByMid(townMid);
Town localTown = (Town)
dataContext.localObject(town.getObjectId(), town);
I create two new objects
MapObject mapObject = dataContext.newObject(MapObject.class);
Street street = dataContext.newObject(Street.class);
Now I set the relationships (and some attributes, but ommited here):
street.setTown(localTown);
mapObject.setStreet(street);
mapObject.setMapObjectType(localMot);
but when commited, the town_mid is NULL
[access.QueryLogger:logQuery]: INSERT INTO maps.street (mid, name, town_mid)
VALUES (?, ?, ?)
[access.QueryLogger:logQueryParameters]: [bind: 1->mid:19568962,
2->name:'Ulica Milana Klemenčiča', 3->*town_mid:NULL*]
I printed out all the objects in the data context in the log file Any
idea???
Here is the log file:
[2010/10/13 10:34:47.723] INFO [access.QueryLogger:logQueryStart]: --- will
run 1 query.
[access.QueryLogger:logBeginTransaction]: --- transaction started.
[access.QueryLogger:logQuery]: SELECT t0.id, t0.type FROM
maps.map_object_type t0 WHERE t0.type = ? [bind: 1->type:STREET=3]
[access.QueryLogger:logSelectCount]: === returned 1 row. - took 2 ms.
[access.QueryLogger:logCommitTransaction]: +++ transaction committed.
[access.QueryLogger:logQueryStart]: --- will run 1 query.
[access.QueryLogger:logBeginTransaction]: --- transaction started.
[access.QueryLogger:logQuery]: SELECT t0.name, t0.id, t0.mid, t0.label_y,
t0.label_x FROM maps.town t0 WHERE t0.mid = ? [bind: 1->mid:10083931]
[access.QueryLogger:logSelectCount]: === returned 1 row. - took 4 ms.
[access.QueryLogger:logCommitTransaction]: +++ transaction committed.
[AppModule.ImportService:importStreetsData]: localTown: {<ObjectId:Town,
id=208>; committed; [name=>Ajdovščina; mapObjects=>(..); streets=>(..);
mid=>10083931; labelY=>85131.71; houseNumbers=>(..); labelX=>416031.93]}
[AppModule.ImportService:importStreetsData]: Imported Street:
{<ObjectId:Street, TEMP:000001BA335F1188>; new; [name=>Ulica Milana
Klemenčiča; mapObjects=>(..); town=>{<ObjectId:Town, id=208>};
mid=>19568962; houseNumbers=>(..)]}
NEW objects
{<ObjectId:Street, TEMP:000001BA335F1188>; new; [name=>Ulica Milana
Klemenčiča; mapObjects=>(..); town=>{<ObjectId:Town, id=208>};
mid=>19568962; houseNumbers=>(..)]}
{<ObjectId:MapObject, TEMP:000000BA335E1188>; new;
[mapObjectType=>{<ObjectId:MapObjectType, id=4>}; street=>{<ObjectId:Street,
TEMP:000001BA335F1188>}]}
DELETED objects
MODIFIED objects
{<ObjectId:MapObjectType, id=4>; modified; [mapObjects=>(..); type=>STREET]}
{<ObjectId:Town, id=208>; modified; [name=>Ajdovščina; mapObjects=>(..);
streets=>(..); mid=>10083931; labelY=>85131.71; houseNumbers=>(..);
labelX=>416031.93]}
UNCOMMITED objects
{<ObjectId:Street, TEMP:000001BA335F1188>; new; [name=>Ulica Milana
Klemenčiča; mapObjects=>(..); town=>{<ObjectId:Town, id=208>};
mid=>19568962; houseNumbers=>(..)]}
{<ObjectId:MapObjectType, id=4>; modified; [mapObjects=>(..); type=>STREET]}
{<ObjectId:Town, id=208>; modified; [name=>Ajdovščina; mapObjects=>(..);
streets=>(..); mid=>10083931; labelY=>85131.71; houseNumbers=>(..);
labelX=>416031.93]}
{<ObjectId:MapObject, TEMP:000000BA335E1188>; new;
[mapObjectType=>{<ObjectId:MapObjectType, id=4>}; street=>{<ObjectId:Street,
TEMP:000001BA335F1188>}]}
[access.QueryLogger:logQueryStart]: --- will run 2 queries.
[access.QueryLogger:logBeginTransaction]: --- transaction started.
*[access.QueryLogger:logQuery]: INSERT INTO maps.street (mid, name,
town_mid) VALUES (?, ?, ?)
[access.QueryLogger:logQueryParameters]: [bind: 1->mid:19568962,
2->name:'Ulica Milana Klemenčiča', 3->town_mid:NULL]*
[access.QueryLogger:logGeneratedKey]: Generated PK: street.id = 1
[access.QueryLogger:logUpdateCount]: === updated 1 row.
[access.QueryLogger:logQuery]: INSERT INTO maps.map_object (company_id,
ehis_id, map_object_type_id, poi_id, post_office_id, street_id, town_id)
VALUES (?, ?, ?, ?, ?, ?, ?)
[access.QueryLogger:logQueryParameters]: [bind: 1->company_id:NULL,
2->ehis_id:NULL, 3->map_object_type_id:4, 4->poi_id:NULL,
5->post_office_id:NULL, 6->street_id:1, 7->town_id:NULL]
[access.QueryLogger:logGeneratedKey]: Generated PK: map_object.id = 30617
[access.QueryLogger:logUpdateCount]: === updated 1 row.
[access.QueryLogger:logCommitTransaction]: +++ transaction committed.
This is how the objects are connected
TOWN ------< MAP_OBJECT
TOWN ------< STREET
STREET ----< MAP_OBJECT
Cayenne 3.0.1
Thanks,
Borut
This archive was generated by hypermail 2.0.0 : Wed Oct 13 2010 - 09:03:25 UTC