Well you can use to_char()
function in the select
clause but, you will need to select all the a.num
field separately and not with *
.
And in postgresql you will need to specify a mask for to_char()
function, so it would be to_char(field, mask)
, for example we can supply 'FM999999999999999999'
as a mask to accept the maximum possible digits.
Your query would be something like this:
Select *, to_char(a.num, 'FM999999999999999999') as num from A a WHERE num LIKE '%345%'
You can take a look at Postgresql Data Type Formatting Functions for further details.
To write the query in your code with EntityManager
you can create a native query using .createNativeQuery()
method, this is how should be your code:
em.createNativeQuery("Select *, to_char(a.num, 'FM999999999999999999') as num from A a WHERE num LIKE '%345%'");