-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Mapping the graph
PostPosted: Fri Feb 04, 2011 11:13 am 
Newbie

Joined: Wed Jan 19, 2011 3:56 am
Posts: 2
Hi all, I want to map the graph - nodes, that are connected with edges.
Suppose that we have such model:
Code:
public class Node
{
   public virtual Guid Id { get; set; }
}

public class Edge
{
   public virtual Guid Id { get; set; }
   public virtual Node StartNode { get; set; }
   public virtual Node EndNode { get; set; }
}


Mapping:
Code:
<class name="Node">
  <id name="Id">
    <column name="Id" not-null="true"/>
    <generator class="guid"/>
  </id>
</class>

<class name="Edge">
  <id name="Id">
    <column name="Id" not-null="true"/>
    <generator class="guid"/>
  </id>
  <property name="StartNode" type="EnkiStudio.Model.Node, EnkiStudio"/>
  <property name="EndNode"/>
</class>

But I have mapping exception:
NHibernate.MappingException: Could not determine type for: EnkiStudio.Model.Node, EnkiStudio, for columns: NHibernate.Mapping.Column(StartNode)

How to map StartNode and EndNode to have edges table with foreign keys and cascaded edit operations?


Top
 Profile  
 
 Post subject: Re: Mapping the graph
PostPosted: Fri Feb 04, 2011 4:59 pm 
Newbie

Joined: Wed Jan 19, 2011 3:56 am
Posts: 2
After some workaround I have found the solution mapping StartNode and EndNode like this:
Code:
<many-to-one name="StartNode" column="StartNode_Id" cascade="all"/>

But some question still exists. I use firebird DB and i noticed, that despite of presence of cascade="all" in mapping file, the foreign keys have no cascade statement.
Does it mean that these references aren't cascaded?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.