| Hibernate version:  1.2.0 - alpha
 
 Hi all,
 
 I am trying to map a self join type relation (1-2-1) mapping as described below, but it doesn't appear to work.
 
 Here's a piece of snippet.
 
 I have a table
 
 Task
 (Task_Id number,
 Name varchar,
 Refers_to number,
 Depends_on Number);
 
 the relation is like this
 
 Task__Name ______Refers_To__Depepends_on
 1.........Make Coffee................null...............null
 2.........Drink Coffee................null...............  1
 3.........Make milky coffee........ 1.................   1
 (... and so on)
 
 This is just to illustrate that Refers_to and Depends_on are the "Task ID" itself
 
 Now, in the class, i have the following definition
 
 class Task
 {
 private int taskId;
 private string name;
 private Task refersTo;
 private Task dependsOn;
 //corresponding getters and setters here....
 }
 
 in the mapping file, i have the following for the two properties:
 
 <one-to-one name="RefersTo" class="mynamespace.Task, myAssembly" />
 
 note: I tried putting in foreign-key as "Task_ID", tried changing it to "REFERS_TO" and so on...
 
 There are no errors in loading and running the app, but when I try saving, the Task gets saved as normal, but if any Task is set to REFERS_TO or DEPENDS_ON is not saved.  They are saved as NULL (always)
 
 When loading, the two properties (Task.RefersTo and Task.DependsOn) point to the class itself.
 
 i.e.  If I load ID=1
 the I get
 
 Task t = LoadWithID(1);
 the corresponding values are...
 
 t = Make Coffee
 t.RefersTo = Make Coffee
 t.DependsOn = Make Coffee.
 
 I don't know why these are being set.
 
 Pleas let me know if I have made any mistake or if this is any known issues.
 
 Many thanks
 Sath
 
 
 |