我有2个具有oneTomany关系的实体。实体1具有实体2的列表。但是,当我尝试使用弹簧数据findByEntity2_entity2colomn时,它会激发一个左外部联接来代替内部联接。
实体1
.ToLongDateString
实体2
Console.WriteLine(dt4.ToShortDateString) 'and show 4/4/2019
Console.WriteLine(dt4.ToLongDateString) 'and show Thursday, April 4, 2019
Console.WriteLine(dt4.ToString("MM/dd/yyyy")) 'and show 04/04/2019
生成的查询
public class Entity1 {
@Column(name = "id_alert")
@Id
private Integer alertId;
@OneToMany(mappedBy = "entity1 ", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
private List<Entity2> email;
}
JPA查询
public class Entity2{
@EmbeddedId
private AlertEntityIdentity emailEntityIdentity;
@MapsId("id_alert")
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id_alert", updatable = false, insertable = false)
private Entity1 entity1 ;
}
public class AlertEntityIdentity implements Serializable {
@Column(name = "id_user",nullable = false)
private Long userId;
@Column(name = "id_contact",nullable = false)
private Integer contactId;
@Column(name = "id_alert",nullable = false)
private Integer subscriptionId;
}
如何在不使用本机或HQL查询的情况下更改此行为?