LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Rep: Reputation: 83
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: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
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: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
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: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration