Question

Hi I have this 3 Class:

public class A{

    @ManyToOne
    @JsonIgnore
    private B b;

        .....
}

public class B{

    @OneToOne
    @JsonIgnore
    private C c;

        .....
}

public class C{
        .....
}

I have a findById(id) on my A class, and hibernate do a join to B class, and the it do another join to C class.

But I don't need to get C class' fields, so can I do??

Thank you

Was it helpful?

Solution 2

I solved as suggested:

I add @OneToOne(fetch = FetchType.LAZY) because my filed isn't mandatory..

OTHER TIPS

You could try to set max_fetch_depth hibernate property to a properly value.

From hibernate documentation:

Sets a maximum "depth" for the outer join fetch tree for single-ended associations (one-to-one, many-to-one). A 0 disables default outer join fetching. e.g. recommended values between 0 and 3.

But keep in mind that this will affect your entire project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top