Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 20837 invoked from network); 19 Feb 2011 23:08:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 19 Feb 2011 23:08:20 -0000 Received: (qmail 3412 invoked by uid 500); 19 Feb 2011 23:08:20 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 3194 invoked by uid 500); 19 Feb 2011 23:08:19 -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 3183 invoked by uid 99); 19 Feb 2011 23:08:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Feb 2011 23:08:18 +0000 X-ASF-Spam-Status: No, hits=3.7 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of joysn71@gmail.com designates 74.125.82.52 as permitted sender) Received: from [74.125.82.52] (HELO mail-ww0-f52.google.com) (74.125.82.52) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Feb 2011 23:08:10 +0000 Received: by wwd20 with SMTP id 20so4729859wwd.9 for ; Sat, 19 Feb 2011 15:07:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=/ZUPFCbhxp6TVLt8EkXVyPYjnN4CfETk3Xmzu/znMPA=; b=kAJTGGmD4iTX/bFrcbGJRKpBIrVd9v/DqNuBeGPf3P/Q8Kg12dSplCrc1gFBSEWb5S LO9w1gH+ZoHGgV5oSB6Vi4Wee227hdZi6esVssO941cWgu/qdZwndxoGNwYY5sg5kb5q hbR78qCqDekuRcn4r5sXPier8jF5U47YinJRU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=GVPCG+AloDqg+Bg31yn7DMe9D18WN/cTaxCDc+Xei1g2F6TGY1LPhJ0jxrxisIbTpP GvZD97AhCRrfGt3KnCN1ELJ3qXqio0yXDbEF2DMvhP+m4rVuWFjMM5arWQvTxjERU0Fw zsr03msZJDsISqYoOH+ohnc+PbEqed4MofC+M= MIME-Version: 1.0 Received: by 10.216.173.18 with SMTP id u18mr1953924wel.37.1298156870538; Sat, 19 Feb 2011 15:07:50 -0800 (PST) Received: by 10.216.80.145 with HTTP; Sat, 19 Feb 2011 15:07:50 -0800 (PST) Date: Sun, 20 Feb 2011 00:07:50 +0100 Message-ID: Subject: @Id not loaded when loading an entity From: Chris Joysn To: users@openjpa.apache.org Content-Type: multipart/alternative; boundary=0016e64c1cf0219769049caab349 X-Virus-Checked: Checked by ClamAV on apache.org --0016e64c1cf0219769049caab349 Content-Type: text/plain; charset=ISO-8859-1 Hello, when i load an entity the id value is not populated. The entity that was created using the following test code has the id attribute set correct, and i can verify this in the database table too, but when i re-read the entity the id attribute is not populated. -----8<----- em = getEntityManagerFactory().createEntityManager(); EntityTransaction tx = em.getTransaction(); tx.begin(); // insert order Order order = new Order(); order.setStatus("testStatus"); em.persist(order); tx.commit(); // verify if order was inserted correct final String query = "SELECT o FROM Order AS o WHERE o.status = ?1"; Query q = em.createQuery(query); q.setParameter(1, "testStatus"); Order orderLoaded = null; orderLoaded = (Order) q.getSingleResult(); em.detach(orderLoaded); assertNotNull(orderLoaded); assertTrue(orderLoaded.getId() > 0); assertEquals(order.getStatus(), orderLoaded.getStatus()); -----8<----- i am using OpenJPA 2.0.1 with MySQL JDBC 5.1.10 and MySQL Server 5.1.49. with the following entity: @Entity @Table(name="orders") public class Order implements Serializable { /** serial for Serializable */ private static final long serialVersionUID = -8061887078955032972L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; @Version private int version; @Column(nullable = false, length = 50) private String status; @Column private Date created; ... remaining code skipped ... as i am not able to find a solution via the docs and using the internet, can anybody help on why the id column is not populated? Thanks --0016e64c1cf0219769049caab349--