Return-Path: X-Original-To: apmail-openjpa-users-archive@minotaur.apache.org Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 878C7D71B for ; Mon, 13 Aug 2012 05:39:31 +0000 (UTC) Received: (qmail 29780 invoked by uid 500); 13 Aug 2012 05:39:31 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 29457 invoked by uid 500); 13 Aug 2012 05:39:28 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 29411 invoked by uid 99); 13 Aug 2012 05:39:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Aug 2012 05:39:27 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of zbynek_vavros@cz.ibm.com designates 195.75.94.111 as permitted sender) Received: from [195.75.94.111] (HELO e06smtp15.uk.ibm.com) (195.75.94.111) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Aug 2012 05:39:16 +0000 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 13 Aug 2012 06:38:55 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 13 Aug 2012 06:38:54 +0100 Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by b06cxnps3075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q7D5cmcS16908536 for ; Mon, 13 Aug 2012 05:38:48 GMT Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q7D5EJkc003574 for ; Mon, 13 Aug 2012 01:14:19 -0400 Received: from d06ml460.portsmouth.uk.ibm.com (d06ml460.portsmouth.uk.ibm.com [9.149.76.157]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q7D5EJls003570 for ; Mon, 13 Aug 2012 01:14:19 -0400 Subject: Composite key problem X-KeepSent: 520C7ABE:8646D0B3-C1257A59:001C8786; type=4; name=$KeepSent To: users@openjpa.apache.org X-Mailer: Lotus Notes Release 8.5.3 September 15, 2011 Message-ID: From: Zbynek Vavros Date: Mon, 13 Aug 2012 07:38:46 +0200 X-MIMETrack: Serialize by Router on D06ML460/06/M/IBM(Release 8.5.2FP1 ZX852FP1HF12|September 28, 2011) at 13/08/2012 07:38:47 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII x-cbid: 12081305-0342-0000-0000-0000028C7A71 Hi, Im having trouble with composite key and OpenJPA. I was using hibernate so excuse my lack of OpenJPA knowledge. I have a table already created and one that I cannot modify : CREATE TABLE `admin_skills` ( `admin_id` INT(11) NOT NULL, `account_id` INT(11) NOT NULL, `skill` INT(11) NOT NULL DEFAULT '5', UNIQUE INDEX `account_id` (`account_id`, `admin_id`), INDEX `admin_id` (`admin_id`), CONSTRAINT `admin_skills_ibfk_1` FOREIGN KEY (`admin_id`) REFERENCES `admins` (`idadmin`) ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT `admin_skills_ibfk_2` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON UPDATE CASCADE ON DELETE CASCADE ) I have created following entity/key : @Entity @Table(name = "admin_skills") public class DitaAdminSkill { @EmbeddedId private DitaAdminSkillPK id; @Column(name = "skill") private Integer skill; //getters & setters @Embeddable public class DitaAdminSkillPK implements Serializable{ @ManyToOne @JoinColumn(name = "admin_id") private DitaAdmin admin; @ManyToOne @JoinColumn(name = "account_id") private DitaAccount account; //getters & setters This works just fine with Hibernate 4.1.4Final : ApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[] {"applicationContext.xml", "db_beans.xml"}); DitaAdminSkillDao dispDao = applicationContext.getBean (DitaAdminSkillDao.class); List disp = dispDao.findAll(); System.out.println(disp.get(0).getId().getAccount()); But when I try to run this with OpenJPA I get an error : Unknown column 't0.id' in 'field list' Seems like it is ignoring the @EmbeddedId annotation and tries to select directly the ID, which do not exists. I have been trying to use @IdClass instead but with pretty much same result :( Since OpenJPA has general lack of support/forums/everything, I wasnt able to find anything useful through google. If anyone has any comments, please, it will be more than welcomed. Oh, and I am using OpenJPA 2.1.5 with Maven (tried 2.2.0-SNAPSHOT but does the same) : org.apache.openjpa openjpa-all 2.1.5 Thanks !!!!