Digital Marketing

Create new Object In JPQL Select Statement by Constructor Expression

When you want to retrieve a Data Transfer Object instead of retrieving a full entity or a full graph of objects in a type safe way, then you can create the new Object in the JPQL select statement:
 SELECT NEW ca.i88.it.UserModel(u.name, u.phone) FROM User u;
Here a constructor is used in the SELECT list to return one or more Java instances. The constructor name must be fully qualified.

Popular posts from this blog

How to fix Google Apps Script: Script function not found: doGet

Creating sort index in MySQL

How to fix: df shows no file systems processed on Linux