Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: How to set the begin and end index in entityGraph Fetching.
PostPosted: Mon Mar 13, 2017 1:31 am 
Newbie

Joined: Wed Jul 13, 2016 10:40 pm
Posts: 19
I find that dynamic entityGraph is great api, but what if i want to fetch the first five Object from @OneToMany Set<Object> or List<Object> but not whole one? What setting should I build?


Last edited by JChan on Mon Mar 13, 2017 2:48 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How to customize the fetch size in entityGraph Fetching.
PostPosted: Mon Mar 13, 2017 2:39 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1385
The most efficient way of fetching data with JPA and Hibernate is a JPQL query which allows you to control the size of the fetched elements without any limitation. If you're referring to limiting a collection size while you fetch it eagerly, that's not possible since Hibernate has to fetch it fully.

If you're referring to JDBC fetch size, that can be set with the hibernate.jdbc.fetch_size configuration property.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: How to customize the fetch size in entityGraph Fetching.
PostPosted: Mon Mar 13, 2017 3:24 am 
Newbie

Joined: Wed Jul 13, 2016 10:40 pm
Posts: 19
vlad wrote:
The most efficient way of fetching data with JPA and Hibernate is a JPQL query which allows you to control the size of the fetched elements without any limitation. If you're referring to limiting a collection size while you fetch it eagerly, that's not possible since Hibernate has to fetch it fully.

If you're referring to JDBC fetch size, that can be set with the hibernate.jdbc.fetch_size configuration property.


Thanks first.

I think the query way sometimes hard to manage, especially when u want to change or expand the attributes of ur entity(name or structure). Thus, I prefer using the JPA Metadata Model.

Now I know that the entityGraph fetching is eager only, but what about the CriteriaQuery?
Size can be controlled in CriteriaQuery where JPA Metadata Model is available?


Top
 Profile  
 
 Post subject: Re: How to set the begin and end index in entityGraph Fetching.
PostPosted: Mon Mar 13, 2017 8:22 am 
Newbie

Joined: Wed Jul 13, 2016 10:40 pm
Posts: 19
I have found that TypeQuery Class could solve my problem.

Thanks for your reply again, vlad !!!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.