Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

JPA type casting


Hello,

I am writing a jpa query which involves comparing 2 parameters code1 and code2. however, code1 is a string while code2 is an integer. i tried doing cast(code2 as string) but it's not working. I think it's because cast( something as Type) is supported in hibernate but not in jpa, so in jpa queries, how do you do type casting? Thanks so much.

j

Your rating: None Average: 5 (1 vote)

You may create a new getter

You may create a new getter and setter methods to cast the integer to string and vice verse.

I think it's because cast(

I think it's because cast( something as Type) is supported in hibernate but not in jpa, so in jpa queries, how do you do type casting?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <p> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br /> <br> <strike>
  • Lines and paragraphs break automatically.
  • Use <!--pagebreak--> to create page breaks.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
Just checking to see if you're an actual person rather than a spammer. Sorry for the inconvenience.