You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Tore Halset <ha...@pvv.ntnu.no> on 2006/10/02 22:53:14 UTC

ObjectId question..

Hello.

I am on thin ice here... Trying to test meaningful and compound  
primary keys in the CocoaCayenne ROP client. See the model-info at  
the bottom of this message.

Adding keywords works ok. Changing them are comitted to the database,  
but the returned diff are very strange. This is the returned diff if  
I change the keyword "hopp3" to "hopp4" for the user "halset".

CAYNodeIdChangeOperation {nodeId = CAYObjectId {Keyword; objectIdKeys  
= {KEYWORD = hopp3; USERNAME = halset; }; singleKey = (null);  
singleValue = <null>; tempKey = (null); replacementIdMap = {KEYWORD =  
hopp4; }}; newNodeId = CAYObjectId {Keyword; objectIdKeys = <null>;  
singleKey = KEYWORD; singleValue = hopp4; tempKey = (null);  
replacementIdMap = <null>}}

The original object id is ok . Notice the compound primary key.  
However, the new object id is very strange as it uses the singleKey/ 
singleValue field. I would expect "objectIdKeys" to contain the new  
values and singleKey/singleValue only to be used for tables with a  
single primary key.

One more thing: What is "replacementIdMap" and do I need to use it  
for anything on the ROP client?

  - Tore.

	<db-entity name="T_KEYWORD">
		<db-attribute name="KEYWORD" type="VARCHAR" isPrimaryKey="true"  
isMandatory="true" length="20"/>
		<db-attribute name="USERNAME" type="VARCHAR" isPrimaryKey="true"  
isMandatory="true" length="20"/>
	</db-entity>
	<db-entity name="T_USER">
		<db-attribute name="FULL_NAME" type="VARCHAR" length="40"/>
		<db-attribute name="USERNAME" type="VARCHAR" isPrimaryKey="true"  
isMandatory="true" length="20"/>
	</db-entity>

	<obj-entity name="Keyword" className="no.thc.tracker.data.Keyword"  
clientClassName="no.thc.tracker.client.data.Keyword"  
dbEntityName="T_KEYWORD">
		<obj-attribute name="keyword" type="java.lang.String" db-attribute- 
path="KEYWORD"/>
	</obj-entity>
	<obj-entity name="User" className="no.thc.tracker.data.User"  
clientClassName="no.thc.tracker.client.data.User" dbEntityName="T_USER">
		<obj-attribute name="fullName" type="java.lang.String" db-attribute- 
path="FULL_NAME"/>
		<obj-attribute name="username" type="java.lang.String" db-attribute- 
path="USERNAME"/>
	</obj-entity>

	<db-relationship name="toUser" source="T_KEYWORD" target="T_USER"  
toMany="false">
		<db-attribute-pair source="USERNAME" target="USERNAME"/>
	</db-relationship>

	<db-relationship name="toKeywords" source="T_USER"  
target="T_KEYWORD" toDependentPK="true" toMany="true">
		<db-attribute-pair source="USERNAME" target="USERNAME"/>
	</db-relationship>

	<obj-relationship name="user" source="Keyword" target="User"  
deleteRule="Nullify" db-relationship-path="toUser"/>
	<obj-relationship name="keywords" source="User" target="Keyword"  
deleteRule="Cascade" db-relationship-path="toKeywords"/>


Re: ObjectId question..

Posted by Tore Halset <ha...@pvv.ntnu.no>.
On Oct 2, 2006, at 22:53, Tore Halset wrote:

> The original object id is ok . Notice the compound primary key.  
> However, the new object id is very strange as it uses the singleKey/ 
> singleValue field. I would expect "objectIdKeys" to contain the new  
> values and singleKey/singleValue only to be used for tables with a  
> single primary key.

Looks like a bug. See http://issues.apache.org/cayenne/browse/CAY-675

  - Tore.

Re: ObjectId question..

Posted by Mike Kienenberger <mk...@gmail.com>.
On 10/2/06, Tore Halset <ha...@pvv.ntnu.no> wrote:
> One more thing: What is "replacementIdMap" and do I need to use it
> for anything on the ROP client?

I believe replacementIdMap contains the new value for a primary key.
You can't update the old record if you don't have the old key anymore,
so replacementIdMap stores the new value separately.