Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement support for @orderby #24

Open
mhgrove opened this issue Mar 17, 2010 · 4 comments
Open

implement support for @orderby #24

mhgrove opened this issue Mar 17, 2010 · 4 comments
Labels
Milestone

Comments

@mhgrove
Copy link
Owner

mhgrove commented Mar 17, 2010

No description provided.

@apoza
Copy link

apoza commented Mar 8, 2013

Hello,

I'm using Empire to access to my ontological data base and now I need to use order by clausule to order the results of my consults.

I see that this issue is not solved but I am going to try to implement this funcionality and I was wondering if you can help me to do this (telling me at least a start point to implement this feature or any other suggestion or idea) because may be we can add the solution (if I can implent it) to Empire.

Thanks in advance.

@mhgrove
Copy link
Owner Author

mhgrove commented Mar 8, 2013

RdfGenerator is the class that handles round tripping to/from RDF & Java beans. So most of the work would go there.

You'll find that in the fromRdf method, I'm using a describe to get the relevant triples for transforming a resource from the Graph into a Java bean. You would have to alter how that works and first grab only the relevant predicates, and then for each one, grab the value(s), setting them on the bean. If any of the predicates maps to a field of type Collection, which has an @orderby annotation on it, then you'd have to do a separate query to get the elements of the collection in the specified order.

Pretty much everything you need is already in RdfGenerator, it would just need to be reworked to use the different algorithm for constructing the bean from a URI denoting an individual in the database.

@apoza
Copy link

apoza commented Mar 11, 2013

First of all, thanks for your answer, I have read it and I have some doubts:

I have understood that your idea to solve this problem is to select the order criteria marking bean property with an @orderby annotation (summarizing).

If I am not wrong I would have problems defining one consult with several ordered "order by" clauses when I want to order the results using one criteria and after this first order apply other order/s more. And another problem of using annotations for this issue is that for the same consult some times I will want use one order criteria and other times I will want another order criteria.

May be I misunderstood your solution or I' have come to wrong conclusions.

@mhgrove
Copy link
Owner Author

mhgrove commented Mar 11, 2013

Look at the definition of OrderBy in the JPA spec, you can specify an list of criteria for the order by, one is applied after the other to give you very precise ordering semantics.

If you want to conditionally order by one criteria or another, you should consider loading them locally into a list and applying the sort there. OrderBy is not intended for conditional ordering. You might be able to achieve the same effect using lazy loading and multiple fields with the different orderings, with the lazy loading you should not see much of a performance hit, but that will simply lead to very confusing code in my opinion.

@mhgrove mhgrove modified the milestones: 0.9, 1.0 Jul 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants