From dev-return-16626-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Tue Jun 08 17:38:26 2010 Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 21276 invoked from network); 8 Jun 2010 17:38:26 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 8 Jun 2010 17:38:26 -0000 Received: (qmail 21376 invoked by uid 500); 8 Jun 2010 17:38:25 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 21258 invoked by uid 500); 8 Jun 2010 17:38:25 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 21210 invoked by uid 99); 8 Jun 2010 17:38:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jun 2010 17:38:25 +0000 X-ASF-Spam-Status: No, hits=-1506.2 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jun 2010 17:37:35 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o58HbF9f002495 for ; Tue, 8 Jun 2010 17:37:15 GMT Message-ID: <266601.29001276018634997.JavaMail.jira@thor> Date: Tue, 8 Jun 2010 13:37:14 -0400 (EDT) From: "Krzysztof (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Created: (OPENJPA-1687) @Strategy and @ElementStrategy handling resets/obstructs SQL type setting in the customhandler map() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 @Strategy and @ElementStrategy handling resets/obstructs SQL type setting in the customhandler map() ----------------------------------------------------------------------------------------------------- Key: OPENJPA-1687 URL: https://issues.apache.org/jira/browse/OPENJPA-1687 Project: OpenJPA Issue Type: Bug Affects Versions: 2.0.0 Environment: OS X, Linux Reporter: Krzysztof openJPA advertises itself as an expandable framework and provides @Strategy (and undocumented) @ElementStrategy annotations to create mappings. I would like to create support for already existing JDBC4 standard mapping primitive arrays mapping in i.e. Postgres: java double[]-> SQL float8[] Unfortunately it is not possible to make it work with a @Strategy as enhancer blindly checks if the field is a collection/array and refuses to do anything with it. In the case like this a field should not be delegated to an external table but simply embedded - same way LOBs are, with different toDataStoreValue/toObjectValue pair as provided in the strategy below.. If we use @ElementStrategy, i.e.: @PersistentCollection @ElementStrategy("gaia.cu7.dal.PostgresJPAArrayHandler") @ElementColumns({ @ElementColumn(name="TDOUBLE") }) private double tdouble[]; then enhancer accepts it. Schema synchronisation creates wrong DDL suppressing given SQL type and mapping it to SQL keyword ARRAY. Does this rather simple requirement is not covered by openJPA? Would be grateful for any hints, comments... public class PostgresJPAArrayHandler extends AbstractValueHandler { public PostgresJPAArrayHandler() { } /** * Serialization ID */ private static final long serialVersionUID = 1L; private static final PostgresJPAArrayHandler _instance = new PostgresJPAArrayHandler(); /** * Singleton instance. */ public static PostgresJPAArrayHandler getInstance() { return _instance; } public Column[] map(ValueMapping vm, String name, ColumnIO io, boolean adapt) { Column col = new Column(); col.setName(name); col.setType(JavaSQLTypes.SQL_ARRAY); col.setTypeName("float8[]"); //////<<<--------------------- this gets reset in mergeField or whereabouts return new Column[]{ col }; } public Object toDataStoreValue(ValueMapping vm, Object val, JDBCStore store) { //this has to be array of some integer or double for now if (val instanceof double[]) { try { Array darr = store.getConnection().createArrayOf("double", (Object[]) ( ArrayUtils.toObject((double[])val))); return darr; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; } /** Convert from DB rep into OM representation */ public Object toObjectValue(ValueMapping vm, Object val) { if (val == null) return null; return ArrayUtils.toPrimitive((Double[])val); } } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.