From: | Samuel Gendler <sgendler(at)ideasculptor(dot)com> |
---|---|
To: | stagirus <mamasa(at)stagirus(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql) |
Date: | 2010-10-02 05:03:33 |
Message-ID: | AANLkTi=wYc=JOcXUY4ZmrLjYJfsv9d-iy82bUt9hsTiW@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-jdbc |
subclassing the dialect is almost certainly overkill for what you are trying
to accomplish. Why not just define a UserType that works with a smallint
column and then use it in your mappings wherever you need to map a boolean
to a smallint. That will work in Oracle just as it will in postgres, so you
won't have an incompatibility that requires a code change in order to switch
platforms - it will just be explicit in both platforms. That's way less
invasive (and probably a lot less side effect prone) than trying to modify
the dialect.
As for why no one mentioned it, I think that is because probably every one
of us thinks that's the worst solution to your problem of all those that
have been presented so far. If you lack the experience with hibernate such
that you aren't even aware of the existence of the dialect classes, then you
probably shouldn't be mucking about with modifying them - especially when
hibernate provides a mechanism to solve exactly your problem in the form of
user defined types. I cannot fathom what your resistance to using a user
type might be. Your problem is exactly what they are designed for - to map
an arbitrary java class to an arbitrary database structure. In your case,
the user type will be incredibly simple, since it is mapping a built-in type
to a single column via a nearly trivial conversion mechanism. You could fix
this in 20 minutes or less with a hibernate book and a user type.
On Fri, Oct 1, 2010 at 9:50 PM, stagirus <mamasa(at)stagirus(dot)com> wrote:
>
> Of course my very first post on this topic indicated that we were looking
> for
> a solution for a problem with booleans. It took this long for all of us to
> reach a conclusion that the business of type mappings are handled by
> Hibernate. The following dialect class/API clearly states it.
>
> http://ajava.org/online/hibernate3api/org/hibernate/dialect/PostgreSQLDialect.html#toBooleanValueString(boolean)
>
> Oliver did refer to Hibernate Dialect. Not very clear though. So it is
> becoming evident that the types can be managed within Hibernate API or
> configurations. Overriding just the above API might suffice. I wish you
> guys
> have pointed me to this earlier.
>
> I am good. thanks.
>
>
>
>
> --
> View this message in context:
> http://postgresql.1045698.n5.nabble.com/Re-BUGS-Mapping-Hibernate-boolean-to-smallint-Postgresql-tp2855367p3073605.html
> Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Ajamian | 2010-10-02 12:23:04 | BUG #5689: UPDATE locks index before table resulting in deadlock |
Previous Message | stagirus | 2010-10-02 04:50:27 | Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql) |
From | Date | Subject | |
---|---|---|---|
Next Message | Samuel Gendler | 2010-10-02 05:08:04 | Re: Upgrade to 9 questions |
Previous Message | Oliver Jowett | 2010-10-02 04:58:53 | Re: Upgrade to 9 questions |