ข้อมูลสปริง jpa findAll ที่สร้าง sql ไม่ได้ใช้การเข้าร่วม [ซ้ำกัน]

ฉันมีเอนทิตีดังต่อไปนี้

@Entity
public class User {

    @Id
    private Long id;
    @ManyToOne(cascade = CascadeType.ALL)
    private Type type;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }
}

เรียก findOne () หรือ findAlll () บนเอนทิตีนี้สร้าง sql ที่แตกต่างกัน

ค้นหาทั้งหมด()

Hibernate: 
    select
        user0_.id as id1_1_,
        user0_.type_id as type_id2_1_ 
    from
        user user0_
Hibernate: 
    select
        type0_.id as id1_0_0_,
        type0_.name as name2_0_0_ 
    from
        type type0_ 
    where
        type0_.id=?

ค้นหาหนึ่ง()

Hibernate: 
    select
        user0_.id as id1_1_0_,
        user0_.type_id as type_id2_1_0_,
        type1_.id as id1_0_1_,
        type1_.name as name2_0_1_ 
    from
        user user0_ 
    left outer join
        type type1_ 
            on user0_.type_id=type1_.id 
    where
        user0_.id=?

เหตุใด findAll () ที่สร้าง sql จึงไม่ใช้การเข้าร่วม

ฉันสร้างที่เก็บตัวอย่างตามคำถามนี้

https://github.com/wensimin/jpa-join-query

ขอบคุณ!


person shali    schedule 14.12.2017    source แหล่งที่มา
comment
stackoverflow.com/ คำถาม/36489133/   -  person Maciej Kowalski    schedule 14.12.2017
comment
สวัสดี คำถามนี้ใช้ ManyToOne ไม่ใช่ OneToMany ภายใต้สถานการณ์เหล่านี้ จะไม่มีแถวเพิ่มเติมในชุดผลลัพธ์ เหตุใด findOne() จึงใช้การเข้าร่วม แต่ findAll() ไม่ใช้การเข้าร่วม   -  person shali    schedule 15.12.2017