LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-15-2012, 06:08 PM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Blog Entries: 1

Rep: Reputation: 90
What's the bib deal of uuid with postgres/jdbc?


I'm facing a problem when trying to retrieve an entity with ebeans from a postgresql db. The ID field has type UUID and so I get an error like this:

Code:
Query threw SQLException:ERROR: operator does not exist: d_uuid = character varying
  Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
  Position: 78 
Bind values:[xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx] 
Query was:
select t0.exam as c0, t0.description as c1 
from exam t0
where t0.exam = ?
Thanks for your help
 
Old 03-16-2012, 08:23 AM   #2
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
Well, ebean 2.7.4 solved it. I was using 2.7.0.
 
Old 03-20-2012, 12:34 PM   #3
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
Ok... ebean 2.7.4 didn't solve it. I was able to work normally on friday and all of the sudden the problem started happening again. There's a possible quick hack you can do to solve it (at least, for PgSQL... it's up to you, no warranties) with ebean on source.

Declare a method like this on com.avaje.ebeaninternal.server.type.ScalarTypeUUID.java (it will override ScalarTypeBaseVarchar.bind(DataBind, T)):

Code:
public void bind(DataBind b, UUID value) throws SQLException { 
	if (value == null){
		b.setNull(Types.VARCHAR);
	} else {
		b.setObject(value);
	}
}
Works for me (at least, so far).
 
Old 03-20-2012, 12:58 PM   #4
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
Not completely right. Hope this works for you.

Code:
public void bind(DataBind b, UUID value) throws SQLException { 
	if (value == null){
		b.setNull(Types.JAVA_OBJECT);
	} else {
		b.setObject(value);
	}
}

public boolean isJdbcNative() {
	return true;
}

public int getJdbcType() {
	return Types.JAVA_OBJECT;
}
 
  


Reply

Tags
jdbc, postgres, postgresql, uuid



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change UUID - Edit UUID using the dd command GMHilltop Linux - Newbie 10 10-28-2010 07:39 PM
[SOLVED] Postgres with ossp-uuid wont compile ! zasavage Slackware 6 10-24-2010 05:19 PM
Volume has problems including no uuid in /dev/disk/by-uuid abejarano Linux - Hardware 3 12-31-2008 08:41 PM
after copying partition, how to deal with fstab when it references by UUID ? lumix Linux - Newbie 5 12-09-2008 09:59 PM
Jdbc + Postgres Connexion amit_181 Linux - General 0 07-20-2001 11:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration