Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.3.1
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
From: tomek@terragate.net
Subject: [neo-user] do self references work with autoincremented primary keys?
Date: 20 May 2005 21:04:49 BDT
Hi.
Is it possible to use selft references in combination with auto incremented primary key?
I tried the following example, but it doesn't work.
What do I have to do when the foreign key is the same as the primary as in my example?
Propaby my idea of proceeding is wrong.
Tomek
[...]
<table name="Customer" javaName="Customer" idMethod="native">
<column name="id" javaName="id" primaryKey="true" required="true" type="INTEGER" />
<column name="name" javaName="name" primaryKey="false" required="true" type="VARCHAR" size="50" />
<column name="boss" javaName="boss" primaryKey="false" required="true" type="INTEGER" />
<foreign-key foreignTable="Customer" name="RelBoss">
<reference local="boss" foreign="id" />
</foreign-key>
</table>
</database>
//code
Customer customer = new CustomerFactory(context).CreateObject();
customer.name = "Tomek";
customer.RelBoss = customer; // !!
context.SaveChanges();
I recieved the following log:
21:56:59,425: INSERT INTO Customer (name, boss) VALUES (@name, @boss)
21:56:59,425: @name = Tomek
21:56:59,425: @boss = -1
21:57:01,208: Closed connection to "data source=MSSQL;initial catalog=Movies;user id=sa;"
21:57:01,218: Caught exception while saving changes: Neo.Core.DataStoreSaveException[[NEO] Errors while saving: Die INSERT-Anweisung verstieß gegen die COLUMN FOREIGN KEY SAME TABLE-Einschränkung 'fk_Customer_RelBoss'. Der Konflikt trat in der Movies-Datenbank, Tabelle 'Customer', column 'id' auf.