Reputation: 31
I want to specify join type on two hibernate entities
`
@Entity
@Table(name = "b_template_control")
public class TemplateControl {
@Column(name = "id")
private Long id;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.DETACH)
@JoinColumn(name = "back_validation_id", nullable = false, insertable
= false, updatable = false)
private ValidationRuleBack validationRuleBack;
}
`
as you can see we have @ManyToOne relation, by default hibernate creates INNER JOIN query but I need LEFT JOIN. The question is how could I specify join type using annotations.
Answer It is nullable = false, so how would a left join be different from an inner join?
Upvotes: 2
Views: 3382
Reputation: 997
Please refer the following link.
https://docs.jboss.org/hibernate/core/3.3/api/org/hibernate/FetchMode.html
The join type FetchMode implies, the query will be using an outer join
Upvotes: 3