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

Not equals query error #26

Open
ripta101 opened this issue Feb 22, 2012 · 2 comments
Open

Not equals query error #26

ripta101 opened this issue Feb 22, 2012 · 2 comments

Comments

@ripta101
Copy link

Hi there,

I am wondering if anyone experience issue with <> (not equal) query.
I am not sure if there is something wrong with my code, or if this actually a bug on SimpleJPA or SimpleDB

I receive below error when using '<>' operand in my query:

Status Code: 400, AWS Request ID: f1f24508-e5c9-b307-7eed-4737e3fb4c2d, AWS Error Code: InvalidQueryExpression, AWS Error Message: The specified query expression syntax is not valid.
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:500)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:262)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:166)
at com.amazonaws.services.simpledb.AmazonSimpleDBClient.invoke(AmazonSimpleDBClient.java:739)
at com.amazonaws.services.simpledb.AmazonSimpleDBClient.select(AmazonSimpleDBClient.java:197)
at com.spaceprogram.simplejpa.DomainHelper.selectItems(DomainHelper.java:57)

I have also tried to use '!=' but it does not seem to work:

javax.persistence.PersistenceException: No getter for field: status !
at com.spaceprogram.simplejpa.query.QueryImpl.appendCondition(QueryImpl.java:365)
at com.spaceprogram.simplejpa.query.QueryImpl.toAmazonQuery(QueryImpl.java:270)
at com.spaceprogram.simplejpa.query.QueryImpl.createAmazonQuery(QueryImpl.java:173)
at com.spaceprogram.simplejpa.query.QueryImpl.getResultList(QueryImpl.java:104)

at

If I remove the <> operand then the query runs with no problem. Here is my code snippet:

....
em = factory.createEntityManager();
Query query = em.createQuery("select s from Stuff s where owner=:owner AND status <> :status AND created is not null order by created desc");
query.setParameter("owner", owner);
query.setParameter("status", status);
return (List)query.getResultList();

....

Thanks.

@treeder
Copy link
Member

treeder commented Feb 22, 2012

I believe "not equal" in SimpleDB is: !=

Can you try that?

On Wed, Feb 22, 2012 at 7:52 AM, mautdunia <
reply@reply.github.com

wrote:

Hi there,

I am wondering if anyone experience issue with <> (not equal) query.
I am not sure if there is something wrong with my code, or if this
actually a bug on SimpleJPA or SimpleDB..

I receive below error when using '<>' operand in my query:

Status Code: 400, AWS Request ID: f1f24508-e5c9-b307-7eed-4737e3fb4c2d,
AWS Error Code: InvalidQueryExpression, AWS Error Message: The specified
query expression syntax is not valid.
at
com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:500)
at
com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:262)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:166)
at
com.amazonaws.services.simpledb.AmazonSimpleDBClient.invoke(AmazonSimpleDBClient.java:739)
at
com.amazonaws.services.simpledb.AmazonSimpleDBClient.select(AmazonSimpleDBClient.java:197)
at
com.spaceprogram.simplejpa.DomainHelper.selectItems(DomainHelper.java:57)

I have also tried to use '!=' but it does not seem to work:

javax.persistence.PersistenceException: No getter for field: status !
at
com.spaceprogram.simplejpa.query.QueryImpl.appendCondition(QueryImpl.java:365)
at
com.spaceprogram.simplejpa.query.QueryImpl.toAmazonQuery(QueryImpl.java:270)
at
com.spaceprogram.simplejpa.query.QueryImpl.createAmazonQuery(QueryImpl.java:173)
at
com.spaceprogram.simplejpa.query.QueryImpl.getResultList(QueryImpl.java:104)

at

If I remove the <> operand then the query runs with no problem. Here is my

code snippet:

....
em = factory.createEntityManager();
Query query = em.createQuery("select s from Stuff s where owner=:owner AND
status <> :status AND created is not null order by created desc");
query.setParameter("owner", owner);
query.setParameter("status", status);
return (List)query.getResultList();

....

Thanks.


Reply to this email directly or view it on GitHub:
#26

@ripta101
Copy link
Author

yes, I have tried that, but it returns an exception on QueryImpl class as seen above....

I think somehow SimpleJPA use "<>" for "not equal" operand (based on http://code.google.com/p/simplejpa/wiki/JPAQuery) while SimpleDB expect it to be "!=" (based on http://docs.amazonwebservices.com/AmazonSimpleDB/latest/DeveloperGuide/UsingSelectOperators.html)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants