Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Entity
- public class Customer extends Company {
- @ManyToOne(fetch = FetchType.LAZY, cascade = ALL)
- @JoinTable(name = "company_services",
- joinColumns = @JoinColumn(name = "companyId", insertable = true, updatable = true),
- inverseJoinColumns = @JoinColumn(name = "serviceId", insertable = true, updatable = true))
- private Service service;
- @Entity
- public class Service {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
- Hibernate:
- /* insert com.example.company.Customer
- */ insert
- into
- `
- companies` (
- ...
- )
- values
- (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
- Hibernate:
- select
- last_insert_id()
- Hibernate:
- /* insert com.example.company.Customer
- */ insert
- into
- `
- company_service` (
- `serviceId`, `companyId`
- )
- values
- (?, ?)
Add Comment
Please, Sign In to add comment