Skip to content

Commit 312ee47

Browse files
Entity in Spring projection with no association
1 parent e54eaad commit 312ee47

File tree

1 file changed

+3
-3
lines changed
  • HibernateSpringBootDtoEntityViaProjectionNoAssociation

1 file changed

+3
-3
lines changed

HibernateSpringBootDtoEntityViaProjectionNoAssociation/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
**[Entity Inside Spring Projection](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootDtoEntityViaProjection)**
1+
**[Entity Inside Spring Projection (no association)](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootDtoEntityViaProjectionNoAssociation)**
22

3-
**Description:** If, for any reason, you need an entity in your Spring projection (DTO), then this application shows you how to do it via an example. In this case, there are two entities, `Author` and `Book`, involved in a lazy bidirectional one-to-many association (it can be other association as well, or even no materialized association). And, we want to fetch in a Spring projection the authors as entities, `Author`, and the `title` of the books.
3+
**Description:** If, for any reason, you need an entity in your Spring projection (DTO), then this application shows you how to do it via an example. In this case, there are two entities, `Author` and `Book`, that have no materialized association between them, but, they share the `genre` attribute. We use this attribute to join authors with books via JPQL. And, we want to fetch in a Spring projection the authors as entities, `Author`, and the `title` of the books.
44

55
**Key points:**\
6-
- define two related entities (e.g., `Author` and `Book` in a one-to-many lazy bidirectional relationship)\
6+
- define two unrelated entities (e.g., `Author` and `Book`)\
77
- define the proper Spring projection having `public Author getAuthor()` and `public String getTitle()`\
88
- write a JPQL to fetch data
99

0 commit comments

Comments
 (0)