Basic result set mappings for native SQL queries HD

23.02.2017
Quite often JPQL is not powerful enough to perform the queries you need in real world projects. In general, this is not an issue because JPA is designed as a leaky abstraction and you can use the full potential of SQL by using native queries. The only downside is, that these queries return a List of Object[] instead of the mapped entities and value objects you are used to get from JPQL queries. Each Object[] in the List contains one record returned by the database. You then need to iterate through the array, cast each Object to its specific type and map them to your domain model. This creates lots of repetitive code and type casts. It would be more comfortable, if you could tell the EntityManager to map the result of the query into entities or value objects as it is the case for JPQL statements. The good news is, JPA provides this functionality. It is called SQL result set mapping and in this video, I will show you how to use it to map your query results to managed entities. If you like this video, please give it a thumbs up and share it with your friends and co-workers. Like my channel? Subscribe! ➜ http://bit.ly/2cUsid8 Join the free Member Library: https://goo.gl/dtyIIC Read the accompanying post: http://www.thoughts-on-java.org/result-set-mapping-basics/ Want to connect with me? Blog: http://www.thoughts-on-java.org/ Twitter: https://twitter.com/thjanssen123 Facebook: https://www.facebook.com/thoughtsonjava

Похожие видео

Показать еще