Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tkkvb-0002PO-16 for pgsql-jdbc@arkaria.postgresql.org; Tue, 18 Dec 2012 00:20:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Tkkva-0003WH-0y for pgsql-jdbc@arkaria.postgresql.org; Tue, 18 Dec 2012 00:20:58 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TkkvY-0003W6-SA for pgsql-jdbc@postgresql.org; Tue, 18 Dec 2012 00:20:57 +0000 Received: from moutng.kundenserver.de ([212.227.17.9]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TkkvW-0007k4-A9 for pgsql-jdbc@postgresql.org; Tue, 18 Dec 2012 00:20:56 +0000 Received: from [10.1.1.3] (124-169-225-8.dyn.iinet.net.au [124.169.225.8]) by mrelayeu.kundenserver.de (node=mrbap3) with ESMTP (Nemesis) id 0MY6Nc-1TgNBj2zy4-00VPxe; Tue, 18 Dec 2012 01:20:53 +0100 Message-ID: <50CFB6DB.7030508@2ndquadrant.com> Date: Tue, 18 Dec 2012 08:20:43 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: "Marc G. Fournier" CC: pgsql-jdbc@postgresql.org Subject: Re: JPA + enum == Exception References: In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:/bL+EbyHtfT7pXriqLLjkXbKv3QjHn3C1zH8XpWfj87 +ysE9nXs5XwQhtuRcuxnlfMkEKwTpZcBXBoA1eaZa9UskllQgF B6mJ63vMpvbpuD5lYaByaXVlOnMwToQOoDI7JFp8rB4OQNuTBB TzCQDR0PAEWhjhnzTo8HOhRk6A781AHMcrtqMs4XXwab+nAGsx S375vSGYMOsLa56WXhGVjStnFI+XpU9aSxbnV5fllUBCBbK1GH FR/0/4nUZcWND2NlG9nW/j6c+9LDA93AgkyqYyJUSJXAMnckgz jBWF4z65pjE1ylSdufJE036vMKtYuRdrj279ksjQvTpAYDdkz8 NPnojonIzd/DIN6RLEKU= X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org 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 … reading from the database isn't a problem, but there appears to be an issue with converting from string -> enum when saving it 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 -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc