Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 1797D1337BB9 for ; Mon, 28 Mar 2011 10:05:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 82255-05 for ; Mon, 28 Mar 2011 13:05:42 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from sam.nabble.com (sam.nabble.com [216.139.236.26]) by mail.postgresql.org (Postfix) with ESMTP id 702881337B47 for ; Mon, 28 Mar 2011 10:05:40 -0300 (ADT) Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.69) (envelope-from ) id 1Q4C8a-0003RI-5x for pgsql-jdbc@postgresql.org; Mon, 28 Mar 2011 06:05:40 -0700 Date: Mon, 28 Mar 2011 06:05:40 -0700 (PDT) From: sdavidr To: pgsql-jdbc@postgresql.org Message-ID: <1301317540172-4267556.post@n5.nabble.com> In-Reply-To: References: <1300923357612-4259788.post@n5.nabble.com> <1301299364557-4267176.post@n5.nabble.com> Subject: Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.767 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01, URI_HEX=1.122 X-Spam-Level: X-Archive-Number: 201103/91 X-Sequence-Number: 21646 Ok, that's the hibernate's code that is failing. As it says :Extract the value from the result set (which is assumed to already have been positioned to the apopriate row). Hibernate could receive a lot of numbers from a "returning *" but doesn't know what is the correct value. It expects to be the first element, but if is not, it fails. Normally, the id is the first returned element by postgres, but in some tables that is not true -> when there is a string discriminator in the first column. In another way, method from postgres driver getGeneratedKeys cannot return the full table, isn't it? /** * Extract the value from the result set (which is assumed to already have been positioned to the apopriate row) * and wrp it in the appropriate Java numeric type. * * @param rs The result set from which to extract the value. * @param type The expected type of the value. * @return The extracted value. * @throws SQLException Indicates problems access the result set * @throws IdentifierGenerationException Indicates an unknown type. */ public static Serializable get(ResultSet rs, Type type) throws SQLException, IdentifierGenerationException { if ( ResultSetIdentifierConsumer.class.isInstance( type ) ) { return ( ( ResultSetIdentifierConsumer ) type ).consumeIdentifier( rs ); } if ( CustomType.class.isInstance( type ) ) { final CustomType customType = (CustomType) type; if ( ResultSetIdentifierConsumer.class.isInstance( customType.getUserType() ) ) { return ( (ResultSetIdentifierConsumer) customType.getUserType() ).consumeIdentifier( rs ); } } Class clazz = type.getReturnedClass(); if ( clazz == Long.class ) { return new Long( rs.getLong( 1 ) ); } else if ( clazz == Integer.class ) { return new Integer( rs.getInt( 1 ) ); } else if ( clazz == Short.class ) { return new Short( rs.getShort( 1 ) ); } else if ( clazz == String.class ) { return rs.getString( 1 ); } else if ( clazz == BigInteger.class ) { return rs.getBigDecimal( 1 ).setScale( 0, BigDecimal.ROUND_UNNECESSARY ).toBigInteger(); } else if ( clazz == BigDecimal.class ) { return rs.getBigDecimal( 1 ).setScale( 0, BigDecimal.ROUND_UNNECESSARY ); } else { throw new IdentifierGenerationException( "unrecognized id type : " + type.getName() + " -> " + clazz.getName() ); } } -- View this message in context: http://postgresql.1045698.n5.nabble.com/Problems-with-Hibernate-Discriminators-and-9-0-801-jdbc4-tp4259788p4267556.html Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.