Re: JPA + enum == Exception
От | Craig Ringer |
---|---|
Тема | Re: JPA + enum == Exception |
Дата | |
Msg-id | 50CFB6DB.7030508@2ndquadrant.com обсуждение исходный текст |
Ответ на | JPA + enum == Exception ("Marc G. Fournier" <scrappy@hub.org>) |
Список | pgsql-jdbc |
On 18/12/2012 7:01 AM, Marc G. Fournier wrote: > I'm trying to use enum's in a database, but the java guys are telling me that they are having problems with inserts … readingfrom the database isn't a problem, but there appears to be an issue with converting from string -> enum when savingit back again … > > they are using JPA2 / EJB + Eclipselink … on the jboss side, we are running the latest jdbc driver … You will have issues, and this is a real PITA. You need a custom type handler in EclipseLink to use the JDBC `setObject(...)` method to set the enum. If you use `setString(...)` as is the default when you use a string mapping, PgJDBC will send a parameter of type `text`, and PostgreSQL will complain that it cannot implicitly cast `text` to whatever your enum is. Creating an implicit cast from text to your enum type in the database will work around it. The root of the problem is that PostgreSQL is much too fussy about casting from `text` to other types. Please follow up with details if you want help: - Exact PgJDBC version, not just "the latest" - EclipseLink version - PostgreSQL version - EXACT TEXT OF THE ERROR MESSAGE YOU GET - The query/queries that resulted in the error mesage, as shown in the PostgreSQL logs. You might need to set `log_statement = 'all'` to capture them. -- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
В списке pgsql-jdbc по дате отправления: