pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedEnums - from java to jpa
2+ messages / 2 participants
[nested] [flat]
* Enums - from java to jpa
@ 2009-05-12 14:01 The Jasper <thejasper@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: The Jasper @ 2009-05-12 14:01 UTC (permalink / raw)
To: pgsql-jdbc
L.S.,
We are updating out application to make use of JPA. We have also
introduced postgres enums into our database. Naturally we also have
java enums which mirror the postgres enums. Now...how do I get JPA to
understand that it has different types at either end which are
actually the same. I mostly get ClassCastExceptions where PGObject is
being cast to String. I can't get rid of an enum definition at either
end, I'm stuck with that. So I need to make JPA understand how to map
from one to the other. We use Hibernate as our JPA implementation.
--
Il se peut faire qu'il y ait des vraies démonstrations; mais cela
n'est pas certain. Ainsi, cela ne montre autre chose, sinon qu'il
n'est pas certain que tout soit incertain, à la gloire du pyrrhonisme.
-B. Pascal
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Enums - from java to jpa
@ 2009-05-12 20:19 Guy Rouillier <guyr-ml1@burntmail.com>
parent: The Jasper <thejasper@gmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: Guy Rouillier @ 2009-05-12 20:19 UTC (permalink / raw)
To: pgsql-jdbc
The Jasper wrote:
> L.S.,
>
> We are updating out application to make use of JPA. We have also
> introduced postgres enums into our database. Naturally we also have
> java enums which mirror the postgres enums. Now...how do I get JPA to
> understand that it has different types at either end which are
> actually the same. I mostly get ClassCastExceptions where PGObject is
> being cast to String. I can't get rid of an enum definition at either
> end, I'm stuck with that. So I need to make JPA understand how to map
> from one to the other. We use Hibernate as our JPA implementation.
>
Our project is also using JPA via Hibernate, but with Oracle on the back
end. Here is how we annotate our columns that access Java enums:
@Column(name = "PREGION_ID", precision = 20, scale = 0, nullable = true)
@Type(type = "com.masergy.sales360.persistence.GenericEnumUserType",
parameters = {
@Parameter(name = "enumClass", value =
"com.masergy.sales360.client.model.OmsPricingRegionEnum"),
@Parameter(name = "identifierMethod", value = "toInt"),
@Parameter(name = "valueOfMethod", value = "fromInt") })
GenericEnumUserType implements UserType, ParameterizedType (Hibernate
interfaces.)
--
Guy Rouillier
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2009-05-12 20:19 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-05-12 14:01 Enums - from java to jpa The Jasper <thejasper@gmail.com>
2009-05-12 20:19 ` Guy Rouillier <guyr-ml1@burntmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox