Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 35972 invoked from network); 9 Apr 2008 03:34:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Apr 2008 03:34:18 -0000 Received: (qmail 48982 invoked by uid 500); 9 Apr 2008 03:34:18 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 48954 invoked by uid 500); 9 Apr 2008 03:34:18 -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 48945 invoked by uid 99); 9 Apr 2008 03:34:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Apr 2008 20:34:18 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Apr 2008 03:33:36 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 4A972234C0C1 for ; Tue, 8 Apr 2008 20:31:24 -0700 (PDT) Message-ID: <288596328.1207711884298.JavaMail.jira@brutus> Date: Tue, 8 Apr 2008 20:31:24 -0700 (PDT) From: "Jason Zheng (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Updated: (OPENJPA-564) Set correct DBDictionary properties for MySQL based on MySQL version In-Reply-To: <1688143820.1207711524559.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-564?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Jason Zheng updated OPENJPA-564: -------------------------------- Attachment: openjpa-1.1.0-634377.patch This patch sets three MySQLDictionary properties (DriverDeserializesBlobs, SupportSubselect and AllowsAliasInBulkClause) based on MySQL version or driver version. > Set correct DBDictionary properties for MySQL based on MySQL version > -------------------------------------------------------------------- > > Key: OPENJPA-564 > URL: https://issues.apache.org/jira/browse/OPENJPA-564 > Project: OpenJPA > Issue Type: Improvement > Components: jdbc > Environment: Microsoft Windows XP SP2, Java version = 1.5.0 with MySQL 5.x Database. > Reporter: Jason Zheng > Priority: Minor > Attachments: openjpa-1.1.0-634377.patch > > > MySQL has many improvements since version 4.1. We should update default values of MySQLDictionary properties to reflect these changes. Ideally we should be able to set these properties correctly based on MySQL version, so the users don't need override "openjpa.jdbc.DBDictionary" property in persistence.xml. > These properties include: > 1) DriverDeserializesBlobs (current default value: true) > We added this flag to MySQLDictionary in Kodo4.1 since most MySQL drivers then automatically deserialized BLOBs on calls to ResultSet.getObject. This is actually a bug in MySQL, and that bug(#25328 in MySQL bug database) is already fixed in 5.x driver. Please see http://dev.mysql.com/doc/refman/5.1/en/cj-news-5-0-6.html for details. > 2) SupportSubselect (current default value: false) > MySQL supports sub-select since version 4.1. > 3) AllowsAliasInBulkClause (current default value: false) > This property is only used in DBDictionary.toBulkOperation(): > line 1874: > // if there is only a single table in the select, then we can > // just issue a single DELETE FROM TABLE WHERE > // statement; otherwise, since SQL doesn't allow deleting > // from one of a multi-table select, we need to issue a subselect > // like DELETE FROM TABLE WHERE EXISTS > // (SELECT 1 FROM TABLE t0 WHERE t0.ID = TABLE.ID); also, some > // databases do not allow aliases in delete statements, which > // also causes us to use a subselect > if (sel.getTableAliases().size() == 1 && supportsSubselect > && allowsAliasInBulkClause) { > SQLBuffer from; > if (sel.getFromSelect() != null) > from = getFromSelect(sel, false); > else > from = getFrom(sel, false); > sql.append(from); > appendUpdates(sel, store, sql, params, updateParams, > allowsAliasInBulkClause); > SQLBuffer where = sel.getWhere(); > if (where != null && !where.isEmpty()) { > sql.append(" WHERE "); > sql.append(where); > } > return sql; > } > It confuses me why we need this property (and supportsSubselect) as conditions for single table update/delete. I believe we can set this property to true if we use MySQL version 4.1 or later. Otherwise If we set supportSubselect to true, we will run into problems described in > http://issues.apache.org/jira/browse/OPENJPA-459. Note Patrick had a comment for that issue: > "I believe that the first query (which only involves one table) is due to a fairly trivial-to-resolve limitation of DBDIctionary: currently, if SupportsSubselect is true and AllowsAliasInBulkClause is false, OpenJPA always uses a subselect, even when it would be valid to just omit the aliases." -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.