-->
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: PerformSaveOrUpdate + computed columns (newbie)
PostPosted: Wed Apr 06, 2011 11:15 am 
Newbie

Joined: Wed Apr 06, 2011 10:59 am
Posts: 1
I'm new to dealing with NHibernate, and I try to use this existing code; I hope someone can help out.

I now realize that this question might relate to "Fluent NHibernate".

What should I do with a field that is a computed column in SQL Server? I just need NHibernate to read it up, and I don't want NHibernate to touch it at all when calling PerformSaveOrUpdate.

It's mapped in this filemap:

Map(x => x.Path).ColumnNames.Add("fil_path").Not.Nullable();

I've tried Not.Nullable and Nullable, and no "addition" at all ... but any way there is an error trying to save, either because the field is nullable and the database won't allow data to be saved to this computed field:

The column "fil_path" cannot be modified because it is either a computed column or is the result of a UNION operator.

... or when set to not nullable, I get this:
not-null property references a null or transient value [...].Model.Entities.File.Path

In the "File" entity class of the same project, the Path property looks like this:
public virtual string Path { get; private set; } // Calculated by customer specific formula.
Which seems to be ok... since it should never be assigned by the user.

How do I tell NHibernate and / or "PerformSaveOrUpdate" not to update this specific field?

Edit:
I ended up setting the mapping to ReadOnly, this way:
Map(x => x.Path).ColumnNames.Add("fil_path").ReadOnly();
End Edit


Thanks,
Andreas Jansson


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.