Hibernate ManyToOne FetchType.LAZY is not working?












1














I am using spring 4.1.4.RELEASE + hibernate 4.3.6.Final, here is my entity code:



public class BaseEntity implements Serializable {
}


public class MarketInfo extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private int id;

@Column(name = "market_id", unique = true, length = 15)
private String marketId;

@OneToMany(fetch = FetchType.LAZY, mappedBy = "market")
private List<MarketChannelGroup> channelGroups;

public List<MarketChannelGroup> getChannelGroups() {
return channelGroups;
}

public void setChannelGroups(List<MarketChannelGroup> channelGroups) {
this.channelGroups = channelGroups;
}

...
}

public class MarketChannelGroup extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private int id;


@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "market_id", referencedColumnName = "market_id")
private MarketInfo market;
...
}


From my test I can see the channelGroups in MarketInfo is working fine (if I don't call getChannelGroups(), then channelGroups is null), however if I call getChannelGroups(), the MarketInfo inside each MarketChannelGroup gets fetched, while this should not happen since market's fetch mode is FetchType.LAZY.



From console I do see the following hibernate log when I call its getter:



Hibernate: select channelgro0_.market_id as market_i5_12_1_, channelgro0_.id as id1_9_1_, channelgro0_.id as id1_9_0_, channelgro0_.channel_group_id as channel_2_9_0_, channelgro0_.channel_group_name as channel_3_9_0_, channelgro0_.channel_group_type as channel_4_9_0_, channelgro0_.market_id as market_i5_9_0_ from market_channel_group channelgro0_ where channelgro0_.market_id=?
Hibernate: select marketinfo0_.id as id1_12_0_, marketinfo0_.enable_flag as enable_f2_12_0_, marketinfo0_.enable_time as enable_t3_12_0_, marketinfo0_.market_id as market_i4_12_0_, marketinfo0_.market_name as market_n5_12_0_, marketinfo0_.stb_count as stb_coun6_12_0_ from market_info marketinfo0_ where marketinfo0_.market_id=?
Hibernate: select marketinfo0_.id as id1_12_0_, marketinfo0_.enable_flag as enable_f2_12_0_, marketinfo0_.enable_time as enable_t3_12_0_, marketinfo0_.market_id as market_i4_12_0_, marketinfo0_.market_name as market_n5_12_0_, marketinfo0_.stb_count as stb_coun6_12_0_ from market_info marketinfo0_ where marketinfo0_.market_id=?
Hibernate: select marketinfo0_.id as id1_12_0_, marketinfo0_.enable_flag as enable_f2_12_0_, marketinfo0_.enable_time as enable_t3_12_0_, marketinfo0_.market_id as market_i4_12_0_, marketinfo0_.market_name as market_n5_12_0_, marketinfo0_.stb_count as stb_coun6_12_0_ from market_info marketinfo0_ where marketinfo0_.market_id=?


could anyone help?



UPDATE



there is no optional method for ManyToOne annotation, so the solution in OneToOne doesn't work for my case.










share|improve this question




















  • 1




    Try with optional=false in your ManyToOne association. Refer - stackoverflow.com/a/17987718/1282369
    – tsatiz
    Sep 28 '16 at 13:16










  • Possible duplicate of Hibernate: one-to-one lazy loading, optional = false
    – tsatiz
    Sep 28 '16 at 13:18










  • @tsatiz, optional=false is not recognized by hibernate here, only OneToOne has that optional method.
    – seaguest
    Sep 29 '16 at 2:04










  • ok, can you try to create a field for market_id column and refer the logical name in the relation. something like private int marketId; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "marketId", referencedColumnName = "market_id", insertable = false, updatable = false) private MarketInfo market;
    – tsatiz
    Sep 29 '16 at 2:31












  • about the optional=false option, hibernate 5 has it for @ManyToOne. I didn't check which version you are using. Sorry about that.
    – tsatiz
    Sep 29 '16 at 2:40
















1














I am using spring 4.1.4.RELEASE + hibernate 4.3.6.Final, here is my entity code:



public class BaseEntity implements Serializable {
}


public class MarketInfo extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private int id;

@Column(name = "market_id", unique = true, length = 15)
private String marketId;

@OneToMany(fetch = FetchType.LAZY, mappedBy = "market")
private List<MarketChannelGroup> channelGroups;

public List<MarketChannelGroup> getChannelGroups() {
return channelGroups;
}

public void setChannelGroups(List<MarketChannelGroup> channelGroups) {
this.channelGroups = channelGroups;
}

...
}

public class MarketChannelGroup extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private int id;


@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "market_id", referencedColumnName = "market_id")
private MarketInfo market;
...
}


From my test I can see the channelGroups in MarketInfo is working fine (if I don't call getChannelGroups(), then channelGroups is null), however if I call getChannelGroups(), the MarketInfo inside each MarketChannelGroup gets fetched, while this should not happen since market's fetch mode is FetchType.LAZY.



From console I do see the following hibernate log when I call its getter:



Hibernate: select channelgro0_.market_id as market_i5_12_1_, channelgro0_.id as id1_9_1_, channelgro0_.id as id1_9_0_, channelgro0_.channel_group_id as channel_2_9_0_, channelgro0_.channel_group_name as channel_3_9_0_, channelgro0_.channel_group_type as channel_4_9_0_, channelgro0_.market_id as market_i5_9_0_ from market_channel_group channelgro0_ where channelgro0_.market_id=?
Hibernate: select marketinfo0_.id as id1_12_0_, marketinfo0_.enable_flag as enable_f2_12_0_, marketinfo0_.enable_time as enable_t3_12_0_, marketinfo0_.market_id as market_i4_12_0_, marketinfo0_.market_name as market_n5_12_0_, marketinfo0_.stb_count as stb_coun6_12_0_ from market_info marketinfo0_ where marketinfo0_.market_id=?
Hibernate: select marketinfo0_.id as id1_12_0_, marketinfo0_.enable_flag as enable_f2_12_0_, marketinfo0_.enable_time as enable_t3_12_0_, marketinfo0_.market_id as market_i4_12_0_, marketinfo0_.market_name as market_n5_12_0_, marketinfo0_.stb_count as stb_coun6_12_0_ from market_info marketinfo0_ where marketinfo0_.market_id=?
Hibernate: select marketinfo0_.id as id1_12_0_, marketinfo0_.enable_flag as enable_f2_12_0_, marketinfo0_.enable_time as enable_t3_12_0_, marketinfo0_.market_id as market_i4_12_0_, marketinfo0_.market_name as market_n5_12_0_, marketinfo0_.stb_count as stb_coun6_12_0_ from market_info marketinfo0_ where marketinfo0_.market_id=?


could anyone help?



UPDATE



there is no optional method for ManyToOne annotation, so the solution in OneToOne doesn't work for my case.










share|improve this question




















  • 1




    Try with optional=false in your ManyToOne association. Refer - stackoverflow.com/a/17987718/1282369
    – tsatiz
    Sep 28 '16 at 13:16










  • Possible duplicate of Hibernate: one-to-one lazy loading, optional = false
    – tsatiz
    Sep 28 '16 at 13:18










  • @tsatiz, optional=false is not recognized by hibernate here, only OneToOne has that optional method.
    – seaguest
    Sep 29 '16 at 2:04










  • ok, can you try to create a field for market_id column and refer the logical name in the relation. something like private int marketId; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "marketId", referencedColumnName = "market_id", insertable = false, updatable = false) private MarketInfo market;
    – tsatiz
    Sep 29 '16 at 2:31












  • about the optional=false option, hibernate 5 has it for @ManyToOne. I didn't check which version you are using. Sorry about that.
    – tsatiz
    Sep 29 '16 at 2:40














1












1








1


1





I am using spring 4.1.4.RELEASE + hibernate 4.3.6.Final, here is my entity code:



public class BaseEntity implements Serializable {
}


public class MarketInfo extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private int id;

@Column(name = "market_id", unique = true, length = 15)
private String marketId;

@OneToMany(fetch = FetchType.LAZY, mappedBy = "market")
private List<MarketChannelGroup> channelGroups;

public List<MarketChannelGroup> getChannelGroups() {
return channelGroups;
}

public void setChannelGroups(List<MarketChannelGroup> channelGroups) {
this.channelGroups = channelGroups;
}

...
}

public class MarketChannelGroup extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private int id;


@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "market_id", referencedColumnName = "market_id")
private MarketInfo market;
...
}


From my test I can see the channelGroups in MarketInfo is working fine (if I don't call getChannelGroups(), then channelGroups is null), however if I call getChannelGroups(), the MarketInfo inside each MarketChannelGroup gets fetched, while this should not happen since market's fetch mode is FetchType.LAZY.



From console I do see the following hibernate log when I call its getter:



Hibernate: select channelgro0_.market_id as market_i5_12_1_, channelgro0_.id as id1_9_1_, channelgro0_.id as id1_9_0_, channelgro0_.channel_group_id as channel_2_9_0_, channelgro0_.channel_group_name as channel_3_9_0_, channelgro0_.channel_group_type as channel_4_9_0_, channelgro0_.market_id as market_i5_9_0_ from market_channel_group channelgro0_ where channelgro0_.market_id=?
Hibernate: select marketinfo0_.id as id1_12_0_, marketinfo0_.enable_flag as enable_f2_12_0_, marketinfo0_.enable_time as enable_t3_12_0_, marketinfo0_.market_id as market_i4_12_0_, marketinfo0_.market_name as market_n5_12_0_, marketinfo0_.stb_count as stb_coun6_12_0_ from market_info marketinfo0_ where marketinfo0_.market_id=?
Hibernate: select marketinfo0_.id as id1_12_0_, marketinfo0_.enable_flag as enable_f2_12_0_, marketinfo0_.enable_time as enable_t3_12_0_, marketinfo0_.market_id as market_i4_12_0_, marketinfo0_.market_name as market_n5_12_0_, marketinfo0_.stb_count as stb_coun6_12_0_ from market_info marketinfo0_ where marketinfo0_.market_id=?
Hibernate: select marketinfo0_.id as id1_12_0_, marketinfo0_.enable_flag as enable_f2_12_0_, marketinfo0_.enable_time as enable_t3_12_0_, marketinfo0_.market_id as market_i4_12_0_, marketinfo0_.market_name as market_n5_12_0_, marketinfo0_.stb_count as stb_coun6_12_0_ from market_info marketinfo0_ where marketinfo0_.market_id=?


could anyone help?



UPDATE



there is no optional method for ManyToOne annotation, so the solution in OneToOne doesn't work for my case.










share|improve this question















I am using spring 4.1.4.RELEASE + hibernate 4.3.6.Final, here is my entity code:



public class BaseEntity implements Serializable {
}


public class MarketInfo extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private int id;

@Column(name = "market_id", unique = true, length = 15)
private String marketId;

@OneToMany(fetch = FetchType.LAZY, mappedBy = "market")
private List<MarketChannelGroup> channelGroups;

public List<MarketChannelGroup> getChannelGroups() {
return channelGroups;
}

public void setChannelGroups(List<MarketChannelGroup> channelGroups) {
this.channelGroups = channelGroups;
}

...
}

public class MarketChannelGroup extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private int id;


@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "market_id", referencedColumnName = "market_id")
private MarketInfo market;
...
}


From my test I can see the channelGroups in MarketInfo is working fine (if I don't call getChannelGroups(), then channelGroups is null), however if I call getChannelGroups(), the MarketInfo inside each MarketChannelGroup gets fetched, while this should not happen since market's fetch mode is FetchType.LAZY.



From console I do see the following hibernate log when I call its getter:



Hibernate: select channelgro0_.market_id as market_i5_12_1_, channelgro0_.id as id1_9_1_, channelgro0_.id as id1_9_0_, channelgro0_.channel_group_id as channel_2_9_0_, channelgro0_.channel_group_name as channel_3_9_0_, channelgro0_.channel_group_type as channel_4_9_0_, channelgro0_.market_id as market_i5_9_0_ from market_channel_group channelgro0_ where channelgro0_.market_id=?
Hibernate: select marketinfo0_.id as id1_12_0_, marketinfo0_.enable_flag as enable_f2_12_0_, marketinfo0_.enable_time as enable_t3_12_0_, marketinfo0_.market_id as market_i4_12_0_, marketinfo0_.market_name as market_n5_12_0_, marketinfo0_.stb_count as stb_coun6_12_0_ from market_info marketinfo0_ where marketinfo0_.market_id=?
Hibernate: select marketinfo0_.id as id1_12_0_, marketinfo0_.enable_flag as enable_f2_12_0_, marketinfo0_.enable_time as enable_t3_12_0_, marketinfo0_.market_id as market_i4_12_0_, marketinfo0_.market_name as market_n5_12_0_, marketinfo0_.stb_count as stb_coun6_12_0_ from market_info marketinfo0_ where marketinfo0_.market_id=?
Hibernate: select marketinfo0_.id as id1_12_0_, marketinfo0_.enable_flag as enable_f2_12_0_, marketinfo0_.enable_time as enable_t3_12_0_, marketinfo0_.market_id as market_i4_12_0_, marketinfo0_.market_name as market_n5_12_0_, marketinfo0_.stb_count as stb_coun6_12_0_ from market_info marketinfo0_ where marketinfo0_.market_id=?


could anyone help?



UPDATE



there is no optional method for ManyToOne annotation, so the solution in OneToOne doesn't work for my case.







java spring hibernate jpa lazy-loading






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 29 '16 at 2:13







seaguest

















asked Sep 28 '16 at 12:55









seaguestseaguest

1,24321430




1,24321430








  • 1




    Try with optional=false in your ManyToOne association. Refer - stackoverflow.com/a/17987718/1282369
    – tsatiz
    Sep 28 '16 at 13:16










  • Possible duplicate of Hibernate: one-to-one lazy loading, optional = false
    – tsatiz
    Sep 28 '16 at 13:18










  • @tsatiz, optional=false is not recognized by hibernate here, only OneToOne has that optional method.
    – seaguest
    Sep 29 '16 at 2:04










  • ok, can you try to create a field for market_id column and refer the logical name in the relation. something like private int marketId; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "marketId", referencedColumnName = "market_id", insertable = false, updatable = false) private MarketInfo market;
    – tsatiz
    Sep 29 '16 at 2:31












  • about the optional=false option, hibernate 5 has it for @ManyToOne. I didn't check which version you are using. Sorry about that.
    – tsatiz
    Sep 29 '16 at 2:40














  • 1




    Try with optional=false in your ManyToOne association. Refer - stackoverflow.com/a/17987718/1282369
    – tsatiz
    Sep 28 '16 at 13:16










  • Possible duplicate of Hibernate: one-to-one lazy loading, optional = false
    – tsatiz
    Sep 28 '16 at 13:18










  • @tsatiz, optional=false is not recognized by hibernate here, only OneToOne has that optional method.
    – seaguest
    Sep 29 '16 at 2:04










  • ok, can you try to create a field for market_id column and refer the logical name in the relation. something like private int marketId; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "marketId", referencedColumnName = "market_id", insertable = false, updatable = false) private MarketInfo market;
    – tsatiz
    Sep 29 '16 at 2:31












  • about the optional=false option, hibernate 5 has it for @ManyToOne. I didn't check which version you are using. Sorry about that.
    – tsatiz
    Sep 29 '16 at 2:40








1




1




Try with optional=false in your ManyToOne association. Refer - stackoverflow.com/a/17987718/1282369
– tsatiz
Sep 28 '16 at 13:16




Try with optional=false in your ManyToOne association. Refer - stackoverflow.com/a/17987718/1282369
– tsatiz
Sep 28 '16 at 13:16












Possible duplicate of Hibernate: one-to-one lazy loading, optional = false
– tsatiz
Sep 28 '16 at 13:18




Possible duplicate of Hibernate: one-to-one lazy loading, optional = false
– tsatiz
Sep 28 '16 at 13:18












@tsatiz, optional=false is not recognized by hibernate here, only OneToOne has that optional method.
– seaguest
Sep 29 '16 at 2:04




@tsatiz, optional=false is not recognized by hibernate here, only OneToOne has that optional method.
– seaguest
Sep 29 '16 at 2:04












ok, can you try to create a field for market_id column and refer the logical name in the relation. something like private int marketId; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "marketId", referencedColumnName = "market_id", insertable = false, updatable = false) private MarketInfo market;
– tsatiz
Sep 29 '16 at 2:31






ok, can you try to create a field for market_id column and refer the logical name in the relation. something like private int marketId; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "marketId", referencedColumnName = "market_id", insertable = false, updatable = false) private MarketInfo market;
– tsatiz
Sep 29 '16 at 2:31














about the optional=false option, hibernate 5 has it for @ManyToOne. I didn't check which version you are using. Sorry about that.
– tsatiz
Sep 29 '16 at 2:40




about the optional=false option, hibernate 5 has it for @ManyToOne. I didn't check which version you are using. Sorry about that.
– tsatiz
Sep 29 '16 at 2:40












3 Answers
3






active

oldest

votes


















0














Move the @OneToMany annotation from the declaration to the getter method, like this:



private List<MarketChannelGroup> channelGroups;

@OneToMany(fetch = FetchType.LAZY, mappedBy = "market")
public List<MarketChannelGroup> getChannelGroups() {
return channelGroups;
}





share|improve this answer





















  • it doesn't work.
    – seaguest
    Sep 29 '16 at 5:07



















0














How is your configuration archive? Look if you are using the filter OpenEntityManagerInViewFilter. If you are using it, always that you call the method Lazy getChannelGroups() the hibernate will get fetch inside each element.






share|improve this answer





















  • There is no filter enabled in my hibernate setting.
    – seaguest
    Sep 29 '16 at 2:11



















0














You have to take oneToMany annotation to getter if @id is on the getter. Lazy works but if you or some framework get the lazy property in that transction the get method fire the select.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39748211%2fhibernate-manytoone-fetchtype-lazy-is-not-working%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Move the @OneToMany annotation from the declaration to the getter method, like this:



    private List<MarketChannelGroup> channelGroups;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "market")
    public List<MarketChannelGroup> getChannelGroups() {
    return channelGroups;
    }





    share|improve this answer





















    • it doesn't work.
      – seaguest
      Sep 29 '16 at 5:07
















    0














    Move the @OneToMany annotation from the declaration to the getter method, like this:



    private List<MarketChannelGroup> channelGroups;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "market")
    public List<MarketChannelGroup> getChannelGroups() {
    return channelGroups;
    }





    share|improve this answer





















    • it doesn't work.
      – seaguest
      Sep 29 '16 at 5:07














    0












    0








    0






    Move the @OneToMany annotation from the declaration to the getter method, like this:



    private List<MarketChannelGroup> channelGroups;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "market")
    public List<MarketChannelGroup> getChannelGroups() {
    return channelGroups;
    }





    share|improve this answer












    Move the @OneToMany annotation from the declaration to the getter method, like this:



    private List<MarketChannelGroup> channelGroups;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "market")
    public List<MarketChannelGroup> getChannelGroups() {
    return channelGroups;
    }






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Sep 28 '16 at 12:59









    MaxinatorMaxinator

    334




    334












    • it doesn't work.
      – seaguest
      Sep 29 '16 at 5:07


















    • it doesn't work.
      – seaguest
      Sep 29 '16 at 5:07
















    it doesn't work.
    – seaguest
    Sep 29 '16 at 5:07




    it doesn't work.
    – seaguest
    Sep 29 '16 at 5:07













    0














    How is your configuration archive? Look if you are using the filter OpenEntityManagerInViewFilter. If you are using it, always that you call the method Lazy getChannelGroups() the hibernate will get fetch inside each element.






    share|improve this answer





















    • There is no filter enabled in my hibernate setting.
      – seaguest
      Sep 29 '16 at 2:11
















    0














    How is your configuration archive? Look if you are using the filter OpenEntityManagerInViewFilter. If you are using it, always that you call the method Lazy getChannelGroups() the hibernate will get fetch inside each element.






    share|improve this answer





















    • There is no filter enabled in my hibernate setting.
      – seaguest
      Sep 29 '16 at 2:11














    0












    0








    0






    How is your configuration archive? Look if you are using the filter OpenEntityManagerInViewFilter. If you are using it, always that you call the method Lazy getChannelGroups() the hibernate will get fetch inside each element.






    share|improve this answer












    How is your configuration archive? Look if you are using the filter OpenEntityManagerInViewFilter. If you are using it, always that you call the method Lazy getChannelGroups() the hibernate will get fetch inside each element.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Sep 28 '16 at 13:16









    Fred BrasilFred Brasil

    113




    113












    • There is no filter enabled in my hibernate setting.
      – seaguest
      Sep 29 '16 at 2:11


















    • There is no filter enabled in my hibernate setting.
      – seaguest
      Sep 29 '16 at 2:11
















    There is no filter enabled in my hibernate setting.
    – seaguest
    Sep 29 '16 at 2:11




    There is no filter enabled in my hibernate setting.
    – seaguest
    Sep 29 '16 at 2:11











    0














    You have to take oneToMany annotation to getter if @id is on the getter. Lazy works but if you or some framework get the lazy property in that transction the get method fire the select.






    share|improve this answer


























      0














      You have to take oneToMany annotation to getter if @id is on the getter. Lazy works but if you or some framework get the lazy property in that transction the get method fire the select.






      share|improve this answer
























        0












        0








        0






        You have to take oneToMany annotation to getter if @id is on the getter. Lazy works but if you or some framework get the lazy property in that transction the get method fire the select.






        share|improve this answer












        You have to take oneToMany annotation to getter if @id is on the getter. Lazy works but if you or some framework get the lazy property in that transction the get method fire the select.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 8:21









        László TóthLászló Tóth

        765




        765






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39748211%2fhibernate-manytoone-fetchtype-lazy-is-not-working%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Costa Masnaga

            Fotorealismo

            Sidney Franklin