-->
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: PostgreSQL dialect and boolean discriminator formulas
PostPosted: Tue Nov 04, 2008 11:53 am 
Newbie

Joined: Mon Sep 26, 2005 12:34 pm
Posts: 7
I'm trying to to do a discriminator based subclass mapping with NHibernate 2.0.1 and PostgreSQL. My discriminator is a formula looking for a specific value in a column to identify a special subclass. I ran into a couple issues.

First off, the documentation fails to mention that, in most cases, you need to surround your formula with parentheses. My first attempt had the discriminator formula as "column = 'magic value'", which hibernate then translated in the query as "... where column = 'magic value' = 1 ..." which of course is invalid.

The second problem, after fixing the parentheses issue, is that boolean values are not handled entirely correctly in postgresql. The postgresql dialects inherit the default implementation of Dialect.ToBooleanValueString, which returns "1" or "0". When working with a boolean formula discriminator, this results in "... where (column = 'magic value') = 1 ...", and postgresql complains: "ERROR 42883: operator does not exist: boolean = integer."

I was able to fix this by creating a custom dialect that overrides ToBooleanValueString and returns the postgresql "TRUE" and "FALSE" constants. Is this a proper fix for this issue? Should I submit a patch to Jira? Do other databases need a similar fix for not having an implicit conversion from integer to boolean?


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.