Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink 2.5 JPA + MONGODB and ORDER BY
EclipseLink 2.5 JPA + MONGODB and ORDER BY [message #1066316] Tue, 02 July 2013 07:16 Go to next message
Bastian Spitzer is currently offline Bastian SpitzerFriend
Messages: 3
Registered: July 2013
Junior Member
Hi,

im having trouble ordering items by 2 parameters. with either one of them it works just fine, but no matter which order i use when ordering after both, its the same in both cases, its allways sorted by lastname first.

here is what i try to do:

Query query = EntitiManager.createQuery("SELECT c FROM ContactHO WHERE c.companyId = :companyId ORDER BY c.firstNameNorm, c.lastNameNorm ASC");


The EclipseLink Debug Out looks fine:

19:24:54.181 FINE  [org.eclipse.persistence.session.vfs:/D:/server/jboss-as-7.1.1.Final/bin/content/module-1-SNAPSHOT.war/WEB-INF/classes/_mongo.sql] (http--127.0.0.1-8180-1) Executing MappedInteraction()
	spec => null
	properties => {mongo.collection=CONTACTHO, mongo.limit=10, mongo.operation=FIND}
	input => [DatabaseRecord(
	CONTACTHO.COMPANYID => 5893435701058912613
	$sort => DatabaseRecord(
	CONTACTHO.FIRSTNAMENORM => 1
	CONTACTHO.LASTNAMENORM => 1))]


but the mongo log, and the resulting sort order is mixed up:

Thu Jun 27 19:24:54.186 [conn21] runQuery called siba.CONTACTHO { $query: { COMPANYID: 5894184253551005013 }, $orderby: { LASTNAMENORM: 1, FIRSTNAMENORM: 1 } }


am i doing something wrong here or is this just a bug?

with kind regards

bastian

[Updated on: Wed, 03 July 2013 12:29]

Report message to a moderator

Re: EclipseLink 2.5 JPA + MONGODB and ORDER BY [message #1066559 is a reply to message #1066316] Wed, 03 July 2013 07:39 Go to previous messageGo to next message
Bastian Spitzer is currently offline Bastian SpitzerFriend
Messages: 3
Registered: July 2013
Junior Member
Hi there, i think i found the problem:

EclipseLink parses Queries into DataBaseRecord's which extend AbstractRecord. AbstractRecord implements the Map interface, but uses two Vector<DatabaseField> for storing fields and values which preserves their insertion order. The MongoAdapter puts them into MongoRecord's. MongoRecord extends HashMap, but doesnt care for ordering - so the order by parameters get ordered by their hashCode's and the initial order gets lost.

If MongoRecord would extend LinkedHashMap rather than HashMap, this problem could be fixed.

i did file a bugreport for this issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=412191

[Updated on: Wed, 03 July 2013 11:22]

Report message to a moderator

Re: EclipseLink 2.5 JPA + MONGODB and ORDER BY [message #1194578 is a reply to message #1066316] Mon, 18 November 2013 15:35 Go to previous message
Bastian Spitzer is currently offline Bastian SpitzerFriend
Messages: 3
Registered: July 2013
Junior Member
Hi there,

any news when this bug will be fixed?

cheers
Previous Topic:javax.naming.NoInitialContextException with DatabaseSession
Next Topic:How to create History for @ElementCollection?
Goto Forum:
  


Current Time: Fri Apr 26 15:02:38 GMT 2024

Powered by FUDForum. Page generated in 0.03066 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top