Guest User

Untitled

a guest
Feb 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. @Entity
  2. @Table(name = "countries", catalog = "librarydb")
  3. @DynamicUpdate
  4. @DynamicInsert
  5. @SelectBeforeUpdate
  6. public class Country {
  7. @Id
  8. @GeneratedValue(strategy = GenerationType.IDENTITY)
  9. private Long id;
  10. @Column(unique = true)
  11. private String countryName;
  12. }
  13.  
  14. @Entity
  15. @Table(name = "authors", catalog = "librarydb")
  16. @DynamicUpdate
  17. @DynamicInsert
  18. @SelectBeforeUpdate
  19. public class Author {
  20. @GeneratedValue(strategy = GenerationType.IDENTITY)
  21. @Id
  22. private Long id;
  23. private String firstName;
  24. private String lastName;
  25.  
  26. @ManyToOne
  27. private Country country;
  28.  
  29. }
  30.  
  31. public interface AuthorRepository extends JpaRepository<Author, Long> {}
  32.  
  33. Hibernate: select author0_.id as id1_0_, author0_.country_id as country_6_0_, author0_.first_name as first_na3_0_, author0_.last_name as last_nam4_0_, from librarydb.authors author0_
  34. Hibernate: select country0_.id as id1_2_0_, country0_.country_name as country_2_2_0_ from librarydb.countries country0_ where country0_.id=?
  35. Hibernate: select country0_.id as id1_2_0_, country0_.country_name as country_2_2_0_ from librarydb.countries country0_ where country0_.id=?
  36. Hibernate: select country0_.id as id1_2_0_, country0_.country_name as country_2_2_0_ from librarydb.countries country0_ where country0_.id=?
  37. Hibernate: select country0_.id as id1_2_0_, country0_.country_name as country_2_2_0_ from librarydb.countries country0_ where country0_.id=?
  38. Hibernate: select country0_.id as id1_2_0_, country0_.country_name as country_2_2_0_ from librarydb.countries country0_ where country0_.id=?
Add Comment
Please, Sign In to add comment