Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Entity
- @Table(name = "countries", catalog = "librarydb")
- @DynamicUpdate
- @DynamicInsert
- @SelectBeforeUpdate
- public class Country {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
- @Column(unique = true)
- private String countryName;
- }
- @Entity
- @Table(name = "authors", catalog = "librarydb")
- @DynamicUpdate
- @DynamicInsert
- @SelectBeforeUpdate
- public class Author {
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Id
- private Long id;
- private String firstName;
- private String lastName;
- @ManyToOne
- private Country country;
- }
- public interface AuthorRepository extends JpaRepository<Author, Long> {}
- 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_
- Hibernate: select country0_.id as id1_2_0_, country0_.country_name as country_2_2_0_ from librarydb.countries country0_ where country0_.id=?
- Hibernate: select country0_.id as id1_2_0_, country0_.country_name as country_2_2_0_ from librarydb.countries country0_ where country0_.id=?
- Hibernate: select country0_.id as id1_2_0_, country0_.country_name as country_2_2_0_ from librarydb.countries country0_ where country0_.id=?
- Hibernate: select country0_.id as id1_2_0_, country0_.country_name as country_2_2_0_ from librarydb.countries country0_ where country0_.id=?
- 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