Home Cast a numeric field to a varchar of a specific length
Reply: 0

Cast a numeric field to a varchar of a specific length

gmc
1#
gmc Published in 2018-01-11 09:27:21Z

I have a numeric id field in an entity that I want to concatenate to some other string. Right now I'm doing:

cb.concat(
  from.get("id").as(String.class)
  , otherString
)

That works and it is translated to CAST(mytable.id AS VARCHAR(255).

I want to be able to cast it to a varchar of lenght 20 VARCHAR(20), because the performance of the query improves exponentially.

Any idea on how to do it?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301114 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO