Created
April 27, 2017 19:45
-
-
Save thjanssen/c85806c9b2c354dbe5da88a0cb5e9286 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
public class Book { | |
@Id | |
@GeneratedValue(strategy = GenerationType.AUTO) | |
@Column(name = "id", updatable = false, nullable = false) | |
private Long id; | |
@Enumerated(EnumType.STRING) | |
private Format format; | |
@ManyToMany | |
@JoinTable(name = "book_author", | |
joinColumns = {@JoinColumn(name = "fk_book")}, | |
inverseJoinColumns = {@JoinColumn(name = "fk_author")}) | |
private List<Author> authors = new ArrayList<Author>(); | |
... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum Format { | |
PAPERBACK, EBOOK; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14:02:09,070 DEBUG [org.hibernate.SQL] - | |
select | |
author0_.id as id1_0_0_, | |
author0_.firstName as firstNam2_0_0_, | |
author0_.lastName as lastName3_0_0_, | |
author0_.version as version4_0_0_ | |
from | |
Author author0_ | |
where | |
author0_.id=? | |
14:02:09,109 DEBUG [org.hibernate.SQL] - | |
select | |
ebooks0_.fk_author as fk_autho2_2_0_, | |
ebooks0_.fk_book as fk_book1_2_0_, | |
book1_.id as id1_1_1_, | |
book1_.format as format2_1_1_, | |
book1_.title as title3_1_1_, | |
book1_.version as version4_1_1_ | |
from | |
book_author ebooks0_ | |
inner join | |
Book book1_ | |
on ebooks0_.fk_book=book1_.id | |
and ( | |
book1_.format = 'EBOOK' | |
) | |
where | |
ebooks0_.fk_author=? | |
14:02:09,117 DEBUG [org.hibernate.SQL] - | |
select | |
printbooks0_.fk_author as fk_autho2_2_0_, | |
printbooks0_.fk_book as fk_book1_2_0_, | |
book1_.id as id1_1_1_, | |
book1_.format as format2_1_1_, | |
book1_.title as title3_1_1_, | |
book1_.version as version4_1_1_ | |
from | |
book_author printbooks0_ | |
inner join | |
Book book1_ | |
on printbooks0_.fk_book=book1_.id | |
and ( | |
book1_.format = 'PAPERBACK' | |
) | |
where | |
printbooks0_.fk_author=? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment