-->
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: [NotSerialized] attribute - does it work in 1.2 beta 2?
PostPosted: Fri Dec 01, 2006 1:51 pm 
Newbie

Joined: Fri Dec 01, 2006 1:24 pm
Posts: 4
Hibernate version:
1.2 beta 2


I have used Hibernate in J2EE for the past year. I am trying to use NHibernate in a .Net 1.1 project and I am having problems trying to control the serialization of a property using the [NotSerialized] (I have tries 3 different spellings) attribute in the C# class. This is easy in the Java version. I keep getting a property Unresolved error...

Has anyone used the [NotSerialized] attribute for NHibernate?

FYI, this problem was cause because of a limitation in the mapping - Class A contains Class B which contains a collection of Class C. This works until you try to make a copy of Class B and C - which caused a NHibernate error (which corrupts the DB) - I think the nhibernate documentation calls this a collection element and is NOT supported. Therefore, I changed the design to use a weak reference between Class A and Class B and have Class manually 'Get any request for Class B from the DB' (simulating lazy loading). This all works until I try to make a copy of Class B (for user editing). The local instance variable in Class A of Class B causes a mapping problem even though I have the NotSerialized attribute associated with the property.

[NotSerialized]
Class B <- for the property definition

My guess is the Beta code is looking at the object and not respecting the [NotSerialized] attribute and creating the mapping code within the NHibernate system, and that mapping code cannot find the Get/Set routines for the property (which should not be there) causing the “Unresolved Error”.

Any help would be appreciated.

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
SQL Server 2000 SP4
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 01, 2006 4:00 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
What is the connection between [NotSerialized] and NHibernate?
From your post, it seems that you consider this attribute something that NHibernate should use to not persist the assoication.
Am I correct?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 01, 2006 5:04 pm 
Newbie

Joined: Fri Dec 01, 2006 1:24 pm
Posts: 4
Thank you for the reply. Here is a link to MSDN that I am referencing concerning serialization:

http://msdn2.microsoft.com/en-us/library/axwwbcs6.aspx

Clearly I am doing something wrong in my use of NHibernate, but I was hoping that the [NonSerialized] attribute would work similar to the Java transient variable attribute which tell Hibernate NOT to map or save the that property (on save/flush).

Is there a way to tell NHibernate to ignore a property or variable from being mapped?

Thanks again for the help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 01, 2006 5:57 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
Serialization and mapping are two different concepts.
If you don't want to map a property, just don't include it in the mapping file


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.