Skip site navigation (1) Skip section navigation (2)

Re: Java persistence with enum types

From: Susannah <cyclingrelf(at)googlemail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Java persistence with enum types
Date: 2009-05-25 12:01:30
Message-ID: 23705886.post@talk.nabble.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
Hi,

Thanks for trying to help Craig, but I had tried the @enumerated annotation
already with the same error message. The @enumerated annotation doesn't
return an enum type to Postgres, but instead returns the ordinal value (by
default) or a string value of the enum. This means I get either the error
message:

Caused by: org.postgresql.util.PSQLException: ERROR: column "typeofname" is
of type typeofnames but expression is of type character varying
(if I use enumtype STRING)

Or

Caused by: org.postgresql.util.PSQLException: ERROR: column "typeofname" is
of type typeofnames but expression is of integer



Craig Ringer wrote:
> 
> Susannah Relf wrote:
>> Hi, I have an enum type in my postgres 8.3 database:
>> 
>> CREATE TYPE typeOfNames AS ENUM ('Latin', 'Common', 'Local');
>> 
>> I am trying to access the database through the Java Persistence API using
>> Netbeans:
>>     @Lob
>>     @Column(name = "typeofname")
>>     private String typeofname;
> 
> One minute with Google:
> 
> @Enumerated
> http://java.sun.com/javaee/5/docs/api/javax/persistence/Enumerated.html
> 
> http://forums.java.net/jive/thread.jspa?messageID=240608
> http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-annotations.html#Enumerated
> ... etc ...
> 
> --
> Craig Ringer
> 
> -- 
> 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
> 
> 

-- 
View this message in context: http://www.nabble.com/Java-persistence-with-enum-types-tp23684815p23705886.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.


In response to

Responses

pgsql-jdbc by date

Next:From: Ioana DanesDate: 2009-05-25 14:59:53
Subject: jdbc rounding value for numeric fields
Previous:From: Craig RingerDate: 2009-05-24 06:29:10
Subject: Re: Java persistence with enum types

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group