0

I'm attempting to retrieve data via my Entity Manager in my Order Facade stateless session bean (Using JPA).

However, I seem to have made an error in calling my table ORDER as it is a reserved keyword.

My attempts at escaping this have not been successful, I've tried backticks, square brackets, prefixing with the schema (APP.ORDER). Documentation of this seems to be lacking.

Query query = em.createQuery("SELECT o FROM Order o", Order.class);

Anyone able to tell me how I can get around this in JPA? Or should I just go and name my table something else?

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
  • 1
    Did you try `"... \"Order\" ..."`. – fuggerjaki61 May 21 '20 at 07:53
  • Just did now thankyou, error is now: `The abstract schema type '"ORDER"' is unknown` I'm beginning to think this might be a bigger issue than reserved keyword, perhaps something is wrong with my entities. – sonovajack May 21 '20 at 07:58
  • 1
    I think [this](https://stackoverflow.com/questions/20193581/error-on-compiling-query-the-abstract-schema-type-entity-is-unknown) might help you with the new error – fuggerjaki61 May 21 '20 at 08:04
  • 1
    Thank you, this prompted me to recheck my Order entity. The annotated table name is indeed ORDER, but the named queries are all selecting from "Order1" (automatically set up via Netbeans, due to the reserved word). It seems that JPQL will not play nice with the reserved word so I think I will have to change my table name. – sonovajack May 21 '20 at 08:32

1 Answers1

0

Did not find a solution other than renaming my table from Order to something else.