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: Creating a proxy instance failed.?????
PostPosted: Mon Apr 28, 2008 1:00 am 
Newbie

Joined: Thu Mar 27, 2008 10:35 pm
Posts: 4
Location: VN
Hi all.
I have 2 class: Customer associate with Customers table and Order associate with Orders table in database.
I'd like to use lazy-load to load Customer without Order. just load the proxy of Order. How can i do that?

Here is mapping files:

//Customer.hbm.xml

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NorthwindCS" assembly="NorthwindCS">
<class name="Customer" table="Customers" >
<id name ="CustomerID" column ="CustomerID" type="String" length="5">
<generator class="assigned"></generator>
</id>
<property name="CompanyName" column ="CompanyName" type ="String" length="40" not-null ="true"/>
<property name="ContactName" column="ContactName" type ="String" length="30"/>
<property name="ContactTitle" column ="ContactTitle" type ="String" length="30"/>
<property name="Address" column="Address" type ="String" length="60"/>
<property name="City" column="City" type ="String" length="15"/>
<property name="Region" column="Region" type ="String" length="15"/>
<property name="PostalCode" column="PostalCode" type ="String" length="10"/>
<property name="Country" column="Country" type ="String" length="15"/>
<property name="Phone" column="Phone" type ="String" length="24"/>
<property name="Fax" column="Fax" type ="String" length="24"/>
<bag name ="Orders" cascade ="all-delete-orphan">
<key column="CustomerID"/>
<one-to-many class ="Order"/>
</bag>
</class>
</hibernate-mapping>

// Order.hbm.xml

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NorthwindCS" assembly="NorthwindCS">
<class name="Order" table="Orders" >
<id name="OrderID" column="OrderID">
<generator class="increment"/>
</id>
<property name="OrderDate" column="OrderDate"/>
<property name="RequiredDate" column="RequiredDate"/>
<property name="ShippedDate" column="ShippedDate"/>
<property name="Freight" column="Freight"/>
<property name="ShipName" column="ShipName"/>
<property name="ShipAddress" column="ShipAddress"/>
<property name="ShipCity" column="ShipCity"/>
<property name="ShipRegion" column="ShipRegion"/>
<property name="ShipPostalCode" column="ShipPostalCode"/>
<property name="ShipCountry" column="ShipCountry"/>
<property name="ShipVia" column="ShipVia"/>
<property name="EmployeeID" column="EmployeeID"/>
<property name="CustomerID" column="CustomerID"/>
<many-to-one name="OCustomer" class="Customer" column="CustomerID"/>

</class>
</hibernate-mapping>

when i call:

an exception was throw : Creating a proxy instance failed.

IQuery query = b.Session.CreateSQLQuery("select o.* from orders o,customers c where o.customerid =? and c.customerid=o.customerid ").AddEntity("dh", typeof(Order));
IList list = query.SetString(0, b.CustomerID).List();
return list;

_________________
JC


Top
 Profile  
 
 Post subject: Creating a proxy instance failed.?????
PostPosted: Mon Apr 28, 2008 2:46 am 
Senior
Senior

Joined: Thu Jun 21, 2007 8:03 am
Posts: 127
Location: UK
Hi,

Can you post the full exception details?

The exception usually indicates other information; for example, are all the methods/properties of your classes marked as virtual?

Regards,
Richard


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.