-->
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.  [ 4 posts ] 
Author Message
 Post subject: Creating a proxy instance failed
PostPosted: Mon Mar 26, 2007 11:14 pm 
Newbie

Joined: Tue Mar 20, 2007 10:58 pm
Posts: 3
I want to map a kind of tree structure: only one class, “General”. The class has a iesi.collection called “childs: elements of childs will be “General Object”.
I need to use lazy initialization, (otherwise all the elements of the tree will be loaded when the 'root' element will be loaded).

When I launch my application, I have this error: “Creating a proxy instance failed”.

Those are my class and my mapping xml:


using System;
using System.Collections.Generic;
using System.Text;

namespace CourseRwDb.mapped
{
class General
{

public General()
{
this._childs = new Iesi.Collections.HashedSet();
}


private int _id;
public virtual int id
{
get
{
return _id;
}
set
{
_id = value;
}
}

private int _father;
public virtual int father
{
get
{
return _father;
}
set
{
_father = value;
}
}

private string _kind;
public virtual string kind
{
get
{
return _kind;
}
set
{
_kind = value;
}
}

private int _crw_ord;
public virtual int crw_ord
{
get
{
return _crw_ord;
}
set
{
_crw_ord = value;
}
}
private string _title;
public virtual string title
{
get
{
return _title;
}
set
{
_title = value;
}
}


private Iesi.Collections.ISet _childs;
public virtual Iesi.Collections.ISet childs
{
get
{
return _childs;
}
set
{
_childs = value;
}
}


}
}



<class name="General" table="general" lazy="true" proxy ="General">
<id name="id" column="id" >
<generator class="native" />
</id>
<property name="father" column="father" />
<property name="kind" column="kind" type="String(20)"/>
<property name="title" column="title" type="String"/>
<property name="crw_ord" column="crw_ord" />

<set name="childs" cascade="all-delete-orphan" inverse="true" lazy="true">
<key column="father"/>
<one-to-many class="General"/>
</set>


</class>


I red a lot but I could not find the solution of my problem.

Tanks you
Ciro


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 27, 2007 12:38 am 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
well actually, in this situation, you don't need to set the proxy attribute because NH will use the class as a proxy for itself by default. also in your mapping file here, you have a space between "proxy" and the "=".

similarly, i'm not sure of your model, but if General has a one-to-many relationship with a collection of General objects, then it probably needs to have a many-to-one association to itself. something like:

Code:
<class name="General" table="general" lazy="true" proxy="General">
  <id name="id" column="id" >
    <generator class="native" />
  </id>
  <version name="version" type="long"/>

  <!--property name="father" column="father" /-->

  <property name="kind" column="kind" type="String(20)"/>
  <property name="title" column="title" type="String"/>
  <property name="crw_ord" column="crw_ord" />

  <many-to-one name="father" column="father" cascade="save-update" class="General" />

  <set name="childs" cascade="all-delete-orphan" inverse="true" lazy="true">
    <key column="father"/>
    <one-to-many class="General"/>
  </set>
</class>

this is the true definition of the Composite Pattern.

-devon


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 27, 2007 7:56 pm 
Newbie

Joined: Tue Mar 20, 2007 10:58 pm
Posts: 3
devonl wrote:
well actually, in this situation, you don't need to set the proxy attribute because NH will use the class as a proxy for itself by default. also in your mapping file here, you have a space between "proxy" and the "=".

similarly, i'm not sure of your model, but if General has a one-to-many relationship with a collection of General objects, then it probably needs to have a many-to-one association to itself. something like:

Code:
<class name="General" table="general" lazy="true" proxy="General">
  <id name="id" column="id" >
    <generator class="native" />
  </id>
  <version name="version" type="long"/>

  <!--property name="father" column="father" /-->

  <property name="kind" column="kind" type="String(20)"/>
  <property name="title" column="title" type="String"/>
  <property name="crw_ord" column="crw_ord" />

  <many-to-one name="father" column="father" cascade="save-update" class="General" />

  <set name="childs" cascade="all-delete-orphan" inverse="true" lazy="true">
    <key column="father"/>
    <one-to-many class="General"/>
  </set>
</class>

this is the true definition of the Composite Pattern.

-devon
did not work...
I have tried...
...tried to cut 'proxy' attribute
...tried to cut space between "proxy" and the "="
...tried to add the property "father" and to add the many-to-one father

but I always get the same old exception: "Creating a proxy instance failed”.


your answer was anyway useful, for me it is important to have the "true definition of the Composite Pattern"...thanks you


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 1:01 pm 
Newbie

Joined: Mon Apr 16, 2007 11:47 am
Posts: 1
hello,

I got the same message ("Creating a proxy instance failed") and for me it helped to declare my classes as public


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.