Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 81648 invoked from network); 12 Apr 2010 10:22:06 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 12 Apr 2010 10:22:06 -0000 Received: (qmail 14979 invoked by uid 500); 12 Apr 2010 10:22:06 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 14871 invoked by uid 500); 12 Apr 2010 10:22:06 -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 14855 invoked by uid 99); 12 Apr 2010 10:22:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Apr 2010 10:22:05 +0000 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.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Apr 2010 10:22:03 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o3CALfeT024448 for ; Mon, 12 Apr 2010 06:21:41 -0400 (EDT) Message-ID: <11789427.20081271067701256.JavaMail.jira@thor> Date: Mon, 12 Apr 2010 06:21:41 -0400 (EDT) From: "Michael McGovern (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Created: (OPENJPA-1627) ORderBy with @ElementJoinColumn and EmbeddedId uses wrong columns in SQL MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org ORderBy with @ElementJoinColumn and EmbeddedId uses wrong columns in SQL ------------------------------------------------------------------------ Key: OPENJPA-1627 URL: https://issues.apache.org/jira/browse/OPENJPA-1627 Project: OpenJPA Issue Type: Bug Components: sql Affects Versions: 2.0.0-beta3 Environment: Windows 7 32 bit / Oracle XE Reporter: Michael McGovern Typical bank example, Account with Transactions. It is a legacy db so Transaction has compound key - represented by TransactionId class. The problem is that the order by in the generated SQL is for columns mapped in the transaction entity NOT the TransacionId as expected. So the Account class has the following fragment.... @OneToMany(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) @ElementJoinColumn(name="maccno", referencedColumnName="maccno") @OrderBy(value = "_id._processDate ASC, _id._tranSequenceNumber ASC") private LinkedList _transactions; _processDate and _tranSequenceNumber are defined in the TransactionId class. Transaction has the following fragment.... @EmbeddedId private TransactionId _id; @Column(name = "mtrancde") private int _transactionCode; @Column(name = "mamount") private BigDecimal _amount; @Column(name = "mdesc") private String _description; @Column(name = "mactdate") private Date _actualDate; @Column(name = "mbranch") private int _branch; And TransactionId defines the primary key columns.... @Embeddable public class TransactionId { @Column(name = "maccno") private String _accountNumber; @Column(name = "mprocdate") private Date _processDate; @Column(name = "mtranseqno") private int _tranSequenceNumber; However the generated SQL is doing order by on columns mapped in Transaction: executing prepstmnt 23188098 SELECT t0.maccno, t0.mprocdate, t0.mtranseqno, t0.mactdate, t0.mamount, t0.mbranch, t0.mchqcash, t0.mdesc, t0.mtmnlno, t0.mtrancde, t0.mtrnfeed FROM transaction t0 WHERE t0.maccno = ? ORDER BY t0.mamount ASC, t0.mbranch ASC [params=(String) 000734123] (no idea why it chose mamount, mbranch) The last line should be: ORDER BY t0.mprocdate ASC, t0.mtranseqno ASC [params=(String) 000734123] Thanks Michael -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira