Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Constructor Expression

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the use of such an expression in JPQL?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never tried it but if you use a constructor expression, the specified class is not required to be an entity or to be mapped to the database. So you should be able to create instances of any classes using it. I'd like to give it a try.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The Constructor expression is used to organize your result. Suppose your select query return individual fields of one organizable unit, say individual component of address. You want ti view this as an single object class as Address. So, define POJO java class object with the constructor with take all individual return field as parameter and use

new Address(queryfield1, queryfield2.. )

so the select query will return the Address object in query result.

Thanks
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it to some extent. Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic