Home » Eclipse Projects » EclipseLink » Native query on MongoDB don't work with find(Trying to do native query on a mongodb with find leads to exception)
Native query on MongoDB don't work with find [message #1009524] |
Fri, 15 February 2013 04:22  |
Eclipse User |
|
|
|
Hello,
I'm using EclipseLink 2.4.0 with MongoDB 2.2. Due to preceeding error (cf. http://www.eclipse.org/forums/index.php/t/453373/), I try to make native query to turnaround limitation. But the result is not good.
Native query using find are refused on mongoDB side.
The findOne command is send to Mongo as :
query: { $eval: "db.attachmentRequest.findOne({ "EMITTERACCOUNT__id" : "511DDC4517800A501FA9FA40" })", args: {} } ntoreturn: -1 ntoskip: 0
and the result is correct. But if you replace directly on mongo console findOne by find you will get :
{ retval: { value: "DBQuery: clouderialDevDB.attachmentRequest -> undefined" }, ok: 1.0 }
I was able to to a find on EclipseLink side using this :
Query q = em.createNativeQuery("function() { var ret=[]; var cursor = db.attachmentRequest.find(); while (cursor.hasNext()) { ret.push(cursor.next()); } return ret; }", AttachmentRequest.class);
This returns an Array of documents, but EclipseLink can't parse this result :
always give a exception :
Local Exception Stack:
Exception [EclipseLink-6044] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.QueryException
Exception Description: The primary key read from the row [EISMappedRecord(
3 => {EMITTERACCOUNT__id=511DDDAC17808B8294346869, _id=511DDDAC17808B829434686A, CLOSETIME=0, REQUESTTIME=1360911780000, STATUS=0, PAYERACCOUNT__id=511DDDAC17808B8294346868}
2 => {EMITTERACCOUNT__id=511DDC4517800A501FA9FA40, _id=511DDC4517800A501FA9FA41, CLOSETIME=0, REQUESTTIME=1360911420000, STATUS=0, PAYERACCOUNT__id=511DDC4517800A501FA9FA3F}
1 => {EMITTERACCOUNT__id=511D326517806B8E1472CA17, _id=511D326517806B8E1472CA18, CLOSETIME=0, REQUESTTIME=1360867920000, STATUS=0, PAYERACCOUNT__id=511D326517806B8E1472CA16}
10 => {EMITTERACCOUNT__id=511DF7701780143B28CBA76C, _id=511DF7701780143B28CBA76D, CLOSETIME=0, REQUESTTIME=1360918380000, STATUS=0, PAYERACCOUNT__id=511DF76F1780143B28CBA76B}
0 => {EMITTERACCOUNT__id=511D31BC178076CC9DCC2203, _id=511D31BC178076CC9DCC2204, CLOSETIME=0, REQUESTTIME=1360867740000, STATUS=0, PAYERACCOUNT__id=511D31BC178076CC9DCC2202}
7 => {EMITTERACCOUNT__id=511DF6C9178046852A6380B1, _id=511DF6C9178046852A6380B2, CLOSETIME=0, REQUESTTIME=1360918200000, STATUS=0, PAYERACCOUNT__id=511DF6C9178046852A6380B0}
6 => {EMITTERACCOUNT__id=511DF6AF1780270A11F699BB, _id=511DF6AF1780270A11F699BC, CLOSETIME=0, REQUESTTIME=1360918140000, STATUS=0, PAYERACCOUNT__id=511DF6AE1780270A11F699BA}
5 => {EMITTERACCOUNT__id=511DF66117803B563A858F21, _id=511DF66117803B563A858F22, CLOSETIME=0, REQUESTTIME=1360918080000, STATUS=0, PAYERACCOUNT__id=511DF66017803B563A858F20}
4 => {EMITTERACCOUNT__id=511DF53A1780B5BAF50F220A, _id=511DF53A1780B5BAF50F220B, CLOSETIME=0, REQUESTTIME=1360917780000, STATUS=0, PAYERACCOUNT__id=511DF53A1780B5BAF50F2209}
9 => {EMITTERACCOUNT__id=511DF73617801FC86025F423, _id=511DF73617801FC86025F424, CLOSETIME=0, REQUESTTIME=1360918320000, STATUS=0, PAYERACCOUNT__id=511DF73517801FC86025F422}
8 => {EMITTERACCOUNT__id=511DF6F21780BC1B4DFA1279, _id=511DF6F21780BC1B4DFA127A, CLOSETIME=0, REQUESTTIME=1360918200000, STATUS=0, PAYERACCOUNT__id=511DF6F21780BC1B4DFA1278}
13 => {EMITTERACCOUNT__id=511DFAFA17801AC3EA825C98, _id=511DFAFA17801AC3EA825C99, CLOSETIME=0, REQUESTTIME=1360919280000, STATUS=0, PAYERACCOUNT__id=511DFAF917801AC3EA825C97}
11 => {EMITTERACCOUNT__id=511DF7A31780A83CFD4AFC94, _id=511DF7A31780A83CFD4AFC95, CLOSETIME=0, REQUESTTIME=1360918380000, STATUS=0, PAYERACCOUNT__id=511DF7A31780A83CFD4AFC93}
12 => {EMITTERACCOUNT__id=511DF7ED178028B216F1FEA9, _id=511DF7ED178028B216F1FEAA, CLOSETIME=0, REQUESTTIME=1360918500000, STATUS=0, PAYERACCOUNT__id=511DF7ED178028B216F1FEA8})] during the execution of the query was detected to be null. Primary keys must not contain null.
Query: ReadAllQuery(referenceClass=AttachmentRequest )
So my question now : does someone knows how to parse a array of Entity returning by a native query ?
JM.
[Updated on: Fri, 15 February 2013 04:24] by Moderator
|
|
| | | | | |
Goto Forum:
Current Time: Tue Jul 15 02:59:46 EDT 2025
Powered by FUDForum. Page generated in 0.09853 seconds
|