-->
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.  [ 3 posts ] 
Author Message
 Post subject: Empty proxy problem
PostPosted: Tue Jun 13, 2006 10:56 am 
Newbie

Joined: Tue Jun 13, 2006 9:54 am
Posts: 2
I've got the following situation:

A Customer class with a field ContactData. ContactData has a field TelephoneNumber that contains the area code and extension.

I've got a Windows Forms application and I've created a form to edit customer information.

If I close this form I get an ArgumentNullException on the base.Dispose() method.

So I started the debugger and stepped trough the code. My code goes to the Intercept method. The invocation.Method points to the getter of my TelephoneNumber.

But the problem is that invocation.Proceed(args) returns null and that throws the exception.

If I initialise the TelephoneNo field with a = new TelephoneNumber the problems don't occure but because of the cascading effects an empty Telephone instance will be saved to the database.

I'm using Visual Studio 2005 with SQL Server 2005.

What should I do?

Thnx for your help!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 13, 2006 1:36 pm 
Pro
Pro

Joined: Fri Nov 19, 2004 5:52 pm
Posts: 232
Location: Chicago, IL
If you posted your mapping files, that might help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 16, 2006 1:17 am 
Newbie

Joined: Tue Jun 13, 2006 9:54 am
Posts: 2
Here are the mappings of the three classes. I removed a few properties which are not really important.

Customer mappings:

Code:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"
    namespace="Domain_Layer" assembly="DomainLayer">
   <class name="Customer" table="Customers" dynamic-update="true" dynamic-insert="true" lazy="true" >
      <id name="Id" column="Customer_ID" unsaved-value="0">
         <generator class="identity" />
      </id>
      <property name="Name"               column="Name"                              />
      <many-to-one name="ContactData"         column="ContactData_ID"           cascade ="save-update"/>
   </class>
</hibernate-mapping>


ContactData:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"
    namespace="Domain_Layer" assembly="DomainLayer">
   <class name="ContactData" table="ContactData" dynamic-update="true" lazy="true" dynamic-insert ="true">
      <id name="Id" column="ContactData_ID" unsaved-value="0">
         <generator class="native" />
      </id>
   <one-to-one  name="TelephoneNo"    class="TelephoneNumber"   />
   </class>
</hibernate-mapping>



TelephoneNumber:


Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"
    namespace="Domain_Layer" assembly="DomainLayer">
   <class name="TelephoneNumber" table="TelephoneNumbers" dynamic-update="true">
      <id name="Id" column="TelephoneNumber_ID" unsaved-value="0">
         <generator class="native" />
      </id>
      <property name="AreaCode"   column="AreaCode"   />
      <property name="Extension"   column="Extension"   />
   </class>
</hibernate-mapping>
[/quote]

Thnx! :)


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