Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 39907 invoked from network); 30 Apr 2008 18:58:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Apr 2008 18:58:07 -0000 Received: (qmail 80625 invoked by uid 500); 30 Apr 2008 18:58:08 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 80597 invoked by uid 500); 30 Apr 2008 18:58:08 -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 80585 invoked by uid 99); 30 Apr 2008 18:58:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Apr 2008 11:58:08 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of kwsutter@gmail.com designates 64.233.166.182 as permitted sender) Received: from [64.233.166.182] (HELO py-out-1112.google.com) (64.233.166.182) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Apr 2008 18:57:23 +0000 Received: by py-out-1112.google.com with SMTP id w49so672604pyg.36 for ; Wed, 30 Apr 2008 11:57:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=ExpMh68SAH6Sut80wb03wsguS4uumEBARw0v4l+suss=; b=WnEj6Vsah1/d+u5O/q1rrhQ8IzlODq2Gmw6Trs9voo0C0JveoBdpaZIKjJimXtXudmUdYSjn/kyK/bq/8FapC+/JtQLa8tYgGg0MPPrSc1RT+MB9if64/X/XdIGFLWNYtFX/SVlrTJNvX+H+ZolWB6BLE9TxGxz1V47NOG1Ggqc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=EhxuQnqlWeXKzyQAm3oIpP6hMeeGMqDpSLe+lYz1vN4HMcQhOCBzF0yWhoacCk+6IeiFrEOFG7SDMfNf6u1uCAH5RncLGljkhbO2xx/z7eyEJ30BSOHJACuJcacgDBll0LM/GxwLF1CL6O7CGkrCpovYIJwulUqia13sNVOiYKk= Received: by 10.141.113.6 with SMTP id q6mr467201rvm.36.1209581853167; Wed, 30 Apr 2008 11:57:33 -0700 (PDT) Received: by 10.140.140.8 with HTTP; Wed, 30 Apr 2008 11:57:33 -0700 (PDT) Message-ID: <89c0c52c0804301157u55ae1a3t5a12d34db0b895d8@mail.gmail.com> Date: Wed, 30 Apr 2008 13:57:33 -0500 From: "Kevin Sutter" To: dev@openjpa.apache.org Subject: Re: UUIDs In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2389_5247450.1209581853148" References: X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_2389_5247450.1209581853148 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline :-) Quiet doesn't mean we're not busy... :-) My first thought when I read your append is why are you not just using the built-in UUID generator that OpenJPA provides? OpenJPA allows you to use a generator on non-id fields. We can either generate the UUID as a 16 character string or a 32 character hex value. Would this usage suffice for you, or do you have some other requirements for the use of the externalizer? Here's a link to the documentation on the UUID generator: http://openjpa.apache.org/docs/latest/manual/manual.html#jpa_overview_meta_gen Kevin On Wed, Apr 30, 2008 at 9:49 AM, Nikolas Everett wrote: > I tried the attached message on the users list but didn't get any > response. > Will someone on the dev listserve help? I'm researching an ORM solution > for > our company, and can't in good conscience pick one with quiet listservs. > Thanks, > > --Nik > > ---------- Forwarded message ---------- > From: Nikolas Everett > Date: Mon, Apr 28, 2008 at 5:20 PM > Subject: UUIDs > To: users@openjpa.apache.org > > > I tried to search the archives and didn't find anything on this. I'm > using > openjpa 1.0.2 and having problems with UUIDs backed into postgres 8.2. > > I have a class like: > @Entity > @Table(uniqueConstraints={@UniqueConstraint(columnNames="uuid")}) > public class Account { > @Id > @GeneratedValue(strategy=GenerationType.IDENTITY) > private int id; > > @Persistent > @Column(nullable=false) > @Externalizer("java.util.UUID.toString") > @Factory("java.util.UUID.fromString") > @ElementType(UUID.class) > private UUID uuid; > > ...getters and setters... > } > > The uuid column is created as a character varying 255, which is fine for > now. > > I have a method like this: > protected Account getAccountByUuid(UUID uuid) { > Query findAccount = this.em.createQuery("SELECT a FROM Account a > WHERE a.uuid = ?1"); > findAccount.setParameter(1, uuid); > try { > return (Account) findAccount.getSingleResult(); > } catch (NoResultException e) { > Account account = new Account(); > account.setUuid(uuid); > this.em.persist(account); > return account; > } > } > > Which throws an exception like this: > Exception in thread "main" error> org.apache.openjpa.persistence.ArgumentException: The parameter "0" > is of type "java.util.UUID", but the declaration in the query is for type > "java.lang.String". > at > > org.apache.openjpa.persistence.QueryImpl.validateParameter(QueryImpl.java:270) > at > > org.apache.openjpa.persistence.QueryImpl.validateParameters(QueryImpl.java:250) > at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:231) > at > > org.apache.openjpa.persistence.QueryImpl.getSingleResult(QueryImpl.java:300) > at com.companyname.Classname.getAccountByUuid(FetchData.java:73) > > This isn't the behavior documented here: > > http://openjpa.apache.org/docs/latest/manual/ref_guide_pc_scos.html#d0e21916 > > What can I do? > > Thanks in advance, > > --Nik > ------=_Part_2389_5247450.1209581853148--