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.  [ 1 post ] 
Author Message
 Post subject: help
PostPosted: Thu Aug 17, 2006 5:14 am 
Newbie

Joined: Tue Jul 25, 2006 11:06 pm
Posts: 2
I have Class Parent and Child like this:
public class Child
{
public Child()
{

}

public virtual string Name
{
get { return name; }
set { name = value; }
}

public virtual int childId
{
get { return childid; }
set { childId = value; }
}

public virtual Parent Parent
{
get { return parent; }
set { parent = value; }
}

private int childid;
private string name;
private Parent parent;
}


public class Parent
{
public Parent()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public virtual int ParentId
{
get { return parentId; }
set { parentId = value; }
}

public virtual string Name
{
get { return name; }
set { name = value; }
}

public virtual IDictionary Childs
{
get { return childs; }
set { childs = value; }
}

private int parentId;
private string name;
private IDictionary childs = new Hashtable();
}

my code in page:

Parent parent = new Parent();
parent.Name = "test parent";

Child child = new Child();
child.Name = "test child";
child.Parent = parent;

parent.Childs.Add( child, child );

session.Save(parent);
session.Flush();

errorInfor:
System.InvalidCastException: 指定的转换无效。

how to solve this ?


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

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.