Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » [Gemini JPA] How would be the best way to implement fetch pagination in a OSGi Persistence service
[Gemini JPA] How would be the best way to implement fetch pagination in a OSGi Persistence service [message #820870] Wed, 14 March 2012 13:20 Go to next message
Cristiano Gaviao is currently offline Cristiano Gaviao
Messages: 253
Registered: July 2009
Senior Member
Hi,

In my actual project I've concentrate the entity classes in the persistence bundle. Then, I've created some other bundles that is referencing the EMF service and exposing some business services interfaces.

Now I would like to improve the data visualization performance using data pagination to get data lazily.

I would like to hear any comments about this kind of implementation in a OSGi service context.

What kind of info should I pass in the service method to allow me to do this ?

thanks for any comment,

regards,

Cristiano
Re: [Gemini JPA] How would be the best way to implement fetch pagination in a OSGi Persistence servi [message #821690 is a reply to message #820870] Thu, 15 March 2012 13:39 Go to previous messageGo to next message
Mike Keith is currently offline Mike Keith
Messages: 207
Registered: July 2009
Senior Member
Hi Cristiano,

That's a difficult question for someone other than you to answer, really. At a minimum you might want a page number to be passed in, and depending upon whether you want to hard-code a page size inside the service you might also allow the page size as a parameter. You might also have an option to identity the particular data to page through. These are just suggestions, though. I'm sure you'll come up with an API that you are happy with Smile

-Mike
Re: [Gemini JPA] How would be the best way to implement fetch pagination in a OSGi Persistence servi [message #826829 is a reply to message #821690] Thu, 22 March 2012 10:56 Go to previous messageGo to next message
Cristiano Gaviao is currently offline Cristiano Gaviao
Messages: 253
Registered: July 2009
Senior Member
Hi Mike,

I should say that you were right. There are lot of ways to implement what I wanted to...

And I ended creating some generic interface, like the one below, that help me to create both mock and real implementations easily using Declarative Services:

public interface LazyQueryService<RootEntity> {

	List<RootEntity> fetchWithFilter(Map<String, Object> queryFilter,
			Object[] sortPropertyIds, boolean[] sortStates, int startIndex,
			int fetchSize);

	int fetchSizeWithFilter(Map<String, Object> queryFilter);

	void save(List<RootEntity> addedObjects, List<RootEntity> modifiedObjects,
			List<RootEntity> removedObjects);

}


cheers,

Cristiano
Re: [Gemini JPA] How would be the best way to implement fetch pagination in a OSGi Persistence servi [message #832806 is a reply to message #826829] Fri, 30 March 2012 12:03 Go to previous messageGo to next message
Eduardo Frazão is currently offline Eduardo Frazão
Messages: 118
Registered: January 2012
Senior Member
Hi Cristiano.
In some cases, I belive this approach will cause you to implement more methods on your services than you need. Here, when I use a ORM Service, I expose the EntityManager of this service to a specialized component on my views, that can Handle it, and paginate automatically paginate entities. This component uses Criteria, so, you can pass a RootQuery (wen you need filters), and it will handle automatically the pagination, ordering, etc.
Re: [Gemini JPA] How would be the best way to implement fetch pagination in a OSGi Persistence servi [message #835119 is a reply to message #832806] Mon, 02 April 2012 16:32 Go to previous message
Cristiano Gaviao is currently offline Cristiano Gaviao
Messages: 253
Registered: July 2009
Senior Member
Hi Eduardo,

Expose the EntityManager in my case would be a kind difficult just because my services will be accessed by two types of osgi applications: a E4 RCP and an Osgi Web, using asynchronous remote method calls supported by the remote services of ECF.

To easy my life I've created an abstract class that implemented the interface that I've show before and some other common protected methods and the EntityManager is injected in an attribute of it. So, all specialized concrete classes implements its own interfaces(business oriented) and inherit from this abstract class.

regards and thanks for suggestion,

Cristiano
Previous Topic:Where and When does the Driver get instantiated?
Next Topic:Persistence Context caching and synchronization
Goto Forum:
  


Current Time: Thu Apr 17 03:40:02 EDT 2014

Powered by FUDForum. Page generated in 0.02025 seconds