Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgre SQL LIKE for Integer

I've some problem in my project, we use PostgreSQL and Hibernate as ORM. I want to perform search in my table for any column type (INTEGER, STRING, TEXT). Where are some problem with Hibernate, I know what I can execute for example LIKE operator on INTEGER type like this:

select * from Table1 where size::text like '%3';

But damn Hibernate takes ::TEXT as self parameter and throws exception. How I can avoid this error? Thanks.

like image 296
Marat_Galiev Avatar asked Feb 16 '11 09:02

Marat_Galiev


2 Answers

Try doing:

cast(size as text)

It should help.

like image 86
Adrian Serafin Avatar answered Sep 18 '22 03:09

Adrian Serafin


Use CAST:

select * from Table1 where CAST(size AS text) like '%3';
like image 36
Frank Heikens Avatar answered Sep 20 '22 03:09

Frank Heikens