Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Criteria API: How-to cast an entity attribute?
Criteria API: How-to cast an entity attribute? [message #540710] Thu, 17 June 2010 07:01 Go to next message
A. D is currently offline A. DFriend
Messages: 4
Registered: June 2010
Junior Member
How do I build a Criteria API query to get a SQL statement like this:

select customer_no from customers where customer_no::varchar like '100%'

I tried to use the "like" Operator from CriteriaBuilder, but I have no idea how-to cast the numeric cutomer_no to a string (varchar)?

Kind regards,


Re: Criteria API: How-to cast an entity attribute? [message #540890 is a reply to message #540710] Thu, 17 June 2010 14:45 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

What database are you using?

On Oracle and many other databases LIKE will just work with numeric fields.
Otherwise you will need to call some database specific function to convert the numeric to a varchar, you can access the appropriate function for your database using the CriteriaBuilder function() API.

James : Wiki : Book : Blog : Twitter
Previous Topic:NullPointerException using mapped-superclass
Next Topic:support for MaxDB 7.6.x?
Goto Forum:

Current Time: Wed Apr 25 07:14:07 GMT 2018

Powered by FUDForum. Page generated in 0.01306 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software