Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 85969 invoked from network); 1 Mar 2010 07:04:06 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 1 Mar 2010 07:04:06 -0000 Received: (qmail 850 invoked by uid 500); 28 Feb 2010 14:56:04 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 828 invoked by uid 500); 28 Feb 2010 14:56:04 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 815 invoked by uid 99); 28 Feb 2010 14:56:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Feb 2010 14:56:04 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of larry.meadors@gmail.com designates 209.85.223.201 as permitted sender) Received: from [209.85.223.201] (HELO mail-iw0-f201.google.com) (209.85.223.201) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Feb 2010 14:55:55 +0000 Received: by iwn39 with SMTP id 39so2667951iwn.0 for ; Sun, 28 Feb 2010 06:55:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:reply-to:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=QYji+CAtTdB7vjNEM6tNWtsFWPbBa0k/IqtAFOTHRBI=; b=Jb/XB1JyJznHGDWNrlz+0IrBp5xLVhSIS3YY9M75B9Yqkq2OSpqJMvzefJQU6/JJAs 5f7NPjSJUB/BVr7lidMxJXNdfepGEb2WS8grfhZQ/gy7RsW2jK2nBh+1EkE76UzXbmN6 u5ab74BJZmQHIKlnfT7+dETcPb6uS/WqHYtmk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:content-type:content-transfer-encoding; b=EI2A0vprvvBPAXDA+TKIjX2ZvASuZ5xWNfLRBVyeYSyX/8aRDq7l+uiKQHil12jN63 pdSSxTvNoWCEZLNJxcYVmeSsSdjfygzbiZ44Qnlp9DqkKAw4Sk4C5/XE6SoVWK5O0vx7 DqX0UYBOCQxVvYihukmeqCOyv6FSxcxRB3Rfs= MIME-Version: 1.0 Received: by 10.231.162.13 with SMTP id t13mr1026ibx.3.1267368933633; Sun, 28 Feb 2010 06:55:33 -0800 (PST) Reply-To: larry.meadors@gmail.com In-Reply-To: <4B8A3C18.80805@directi.com> References: <4B713A84.1070201@directi.com> <4B73A8AB.5070500@directi.com> <50CA25BD6EEA954FA592C097399942E31A75E752@CM1.wis.local> <4B73BC01.20301@directi.com> <00ce01caab0d$91556de0$b40049a0$@com> <4B74FFB8.4040301@directi.com> <4B8A3C18.80805@directi.com> From: Larry Meadors Date: Sun, 28 Feb 2010 07:55:13 -0700 Message-ID: Subject: Re: java.util.UUID to postgres uuid column To: user-java@ibatis.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable I think the combination of #value# and the type handler should work - it may take some messing around and debugging to figure out what exactly is going on. Unfortunately, I just do not have the free time to do that. :-) If you would like me to block out a couple of hours to figure it out for you, feel free to contact me off list, and I will be glad to provide you with some additional professional support. Larry On Sun, Feb 28, 2010 at 2:49 AM, Vikram Subbarao wro= te: > Hello All, > > Any idea on this? > > Regards > Vikram > > > Vikram Subbarao wrote: > > The uuid in database is stored in a column of type uuid supported by > postgres db. Now when i use the query below, i am passing a string and wo= uld > become VARCHAR to database which results in postgres db complaining that = it > cannot compare 'Character Varying' and 'uuid' values. I understand implic= it > casts happen in certain databases (like sql server), but not in postgres. > > Also, there are performance issues shuttling between UUID (128 bits) and > String (36 Chars for type 4 uuid =3D 576 bits) and then back for a freque= nt > query like this which seems mostly un-necessary if ibatis could understan= d > and add this as a known type, especially since postgress jdbc supports > java.util.UUID as a type. > > Regards > Vikram > > meindert wrote: > > Hi Vikram, > > > > I don=92t use the UUID myself and can=92t answer your question from exper= ience, > but I think the real question would be how the ID is stored in the DB. > > IBATIS error message is is correct to say that the UUID object does not h= ave > a value (like a string or int object) and there is no UUID.getId() > > Assuming you use a =91uniqueidentifier=92 =A0type on the (sql server) db = side, I > would think you need to query the ID as a string; > > > > =A0=A0=A0 > > sqlMapClientTemplate.queryForObject("User.findById", id.toString()); > > > > From sql books online: > > A column or local variable of=A0uniqueidentifier=A0data type can be initi= alized > to a value in the following ways: > > By using the NEWID function. > By converting from a string constant in the > formxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, in which each=A0x=A0is a hexade= cimal > digit in the range 0-9 or a-f. For example, > 6F9619FF-8B86-D011-B42D-00C04FC964FF is a valid=A0uniqueidentifier=A0valu= e. > > Comparison operators can be used with=A0uniqueidentifier=A0values. Howeve= r, > ordering is not implemented by comparing the bit patterns of the two valu= es. > The only operations that can be performed against a=A0uniqueidentifier=A0= value > are comparisons (=3D, <>, <, >, <=3D, >=3D) and checking for NULL (IS NUL= L and IS > NOT NULL). No other arithmetic operators can be used. All column constrai= nts > and properties, except IDENTITY, can be used on the=A0uniqueidentifier=A0= data > type. > > Merge replication and transactional replication with updating subscriptio= ns > useuniqueidentifier=A0columns to guarantee that rows are uniquely identif= ied > across multiple copies of the table. > > > > Regards > > =A0Meindert Hoving > > > > > > From: Vikram Subbarao [mailto:vikram.s@directi.com] > Sent: 11 February 2010 10:13 AM > To: user-java@ibatis.apache.org > Subject: Re: java.util.UUID to postgres uuid column > > > > Does not work - > > =A0=A0=A0 com.ibatis.common.beans.ProbeException: There is no READABLE pr= operty > named 'value' in class 'java.util.UUID' > > Niels Beekman wrote: > > Try #value#, this will use your parameter object directly. Using #id# tri= es > to obtain the id property from it. > > > > ________________________________ > > From: Vikram Subbarao [mailto:vikram.s@directi.com] > Sent: Thursday, February 11, 2010 7:50 AM > To: user-java@ibatis.apache.org > Subject: Re: java.util.UUID to postgres uuid column > > > > With this approach i tried this in a query - > > =A0=A0=A0 > > > When i call this query as - > > =A0=A0=A0 sqlMapClientTemplate.queryForObject("User.findById", id); > > =A0=A0=A0 Note: id is an java.util.UUID object. > > I get an error - > > =A0=A0=A0 com.ibatis.common.beans.ProbeException: There is no READABLE pr= operty > named 'id' in class 'java.util.UUID' > > Regards > Vikram > > Larry Meadors wrote: > > This might work: > > > > public class UUIDTypeHandler implements TypeHandlerCallback { > > =A0=A0=A0 @Override > > =A0=A0=A0 public void setParameter(ParameterSetter setter, Object paramet= er) > > throws SQLException { > > =A0=A0=A0=A0=A0=A0=A0 setter.setObject(parameter); > > =A0=A0=A0 } > > > > =A0=A0=A0 @Override > > =A0=A0=A0 public Object getResult(ResultGetter getter) throws SQLExceptio= n { > > =A0=A0=A0=A0=A0=A0=A0 return getter.getObject(); > > =A0=A0=A0 } > > > > =A0=A0=A0 @Override > > =A0=A0=A0 public Object valueOf(String s) { > > =A0=A0=A0=A0=A0=A0=A0 return UUID.fromString(s); > > =A0=A0=A0 } > > } > > > > Add this in your sqlmapconfig.xml: > > > > > > > > > > Larry > > > > > > > > On Tue, Feb 9, 2010 at 3:35 AM, Vikram Subbarao > wrote: > > > > I am using postgres db and would like to map a java.util.UUID to a postgr= es > > uuid column. Latest postgres driver supports mapping of this if i was > > directly creating my prepared statements but since i use ibatis inbetween= , i > > am unable to achive this as ibatis does not seem to understand that > > java.util.UUID can be based down to jdbc. I could use typehandler if the = db > > column was a VARCHAR, but since the postgres db is a 'uuid' type, i have = =A0no > > option but to use the driver supported option of using java.util.UUID, bu= t > > it does not work with ibatis for me. > > > > Please help me if some one has a solution to this. > > > > Regards > > Vikram > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org > > For additional commands, e-mail: user-java-help@ibatis.apache.org > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org > > For additional commands, e-mail: user-java-help@ibatis.apache.org > > > > > > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 9.0.733 / Virus Database: 271.1.1/2676 - Release Date: 02/10/10 > 21:38:00 --------------------------------------------------------------------- To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org For additional commands, e-mail: user-java-help@ibatis.apache.org