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: Need an INSERT only column mapping strategy
PostPosted: Mon Oct 16, 2006 3:45 am 
Newbie

Joined: Thu Aug 10, 2006 9:43 am
Posts: 7
Location: South West UK
Hi,

Not sure if the subject is correct description of what I'm after so a quick outline of the problem:

I have code which is operating against an existing database which apart from views, and triggers I cannot modify (as its used by other released code)

Now the existing app can't handle nulls in some datatypes such as DATE types (this is in an oracle db) so they use a "magic" value which they interpret as null in the case of a DATE this is 00-00-0000 when I map to this column I get a parse exception from .Net when NHibernate reads the value in the column - in the class the property is a Nullable<DateTime>

So to handle reads I created a view which presents the value as null instead of the magic value

However I also need to insert and update this column if the code attempts to insert a null I can correct with a trigger but this would need a mapping that only INSERT or UPDATE for that column (while reading from the view column)

Can anyone suggest any other strategy to deal with this case?

Hibernate version: 1.2.0

[
Name and version of the database you are using: Oracle 8/9/10



Thanks
Richard


Top
 Profile  
 
 Post subject: Re: Need an INSERT only column mapping strategy
PostPosted: Mon Oct 16, 2006 9:12 am 
Beginner
Beginner

Joined: Wed Aug 03, 2005 8:06 am
Posts: 40
Location: Netherlands
Hi,

Maybe you can create your own type, a bit like http://forum.hibernate.org/viewtopic.php?t=960727&highlight=itype+implementation.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 9:18 am 
Newbie

Joined: Thu Aug 10, 2006 9:43 am
Posts: 7
Location: South West UK
yes that does seem to the be the best answer I created my own special DateTime type ingeriting from IUserType which handles the "magic" values for nulls

I found another example here: http://www.goeleven.com/blog/EntryDetail.aspx?entry=40


Thanks
Richard


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.