Skip to content

Commit a918472

Browse files
Dto Via ResultTransformer And Native Query
1 parent e26e9cd commit a918472

File tree

1 file changed

+5
-5
lines changed
  • HibernateSpringBootDtoResultTransformer

1 file changed

+5
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
**[How To Fetch DTO Via `ResultTransformer` And Native SQL](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootDtoResultTransformer)**
22

3-
**Description:** Fetching more data than needed is prone to performance penalities. Using DTO allows us to extract only the needed data. In this application we rely on Hibernate, `ResultTransformer` and native SQL.
3+
**Description:** Fetching more data than needed is prone to performance penalties. Using DTO allows us to extract only the needed data. In this application we rely on Hibernate, `ResultTransformer` and native SQL.
44

55
**Key points:**
6-
- use `AliasToBeanConstructorResultTransformer` for DTO without setters, but with constructor\
7-
- use `Transformers.aliasToBean()` for DTO with setters\
8-
- use `EntityManager.createNativeQuery()` and `unwrap(org.hibernate.query.NativeQuery.class)`\
9-
- starting with Hibernate 5.2, `ResultTransformer` is deprecated, but until a replacement will be available (probably in Hibernate 6.0) it can be used ([read further](https://discourse.hibernate.org/t/hibernate-resulttransformer-is-deprecated-what-to-use-instead/232))\
6+
- use `AliasToBeanConstructorResultTransformer` for DTO without setters, but with constructor
7+
- use `Transformers.aliasToBean()` for DTO with setters
8+
- use `EntityManager.createNativeQuery()` and `unwrap(org.hibernate.query.NativeQuery.class)`
9+
- starting with Hibernate 5.2, `ResultTransformer` is deprecated, but until a replacement will be available (probably in Hibernate 6.0) it can be used ([read further](https://discourse.hibernate.org/t/hibernate-resulttransformer-is-deprecated-what-to-use-instead/232))
1010
- for using Spring Data Projections check this [recipe](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootDtoViaProjections)
1111

1212
<a href="https://leanpub.com/java-persistence-performance-illustrated-guide"><p align="center"><img src="https://github.com/AnghelLeonard/Hibernate-SpringBoot/blob/master/Java%20Persistence%20Performance%20Illustrated%20Guide.jpg" height="410" width="350"/></p></a>

0 commit comments

Comments
 (0)