arturoams
(Arturo Martínez)
June 14, 2021, 5:17pm
1
Hello,
I am working with an entity called Order, and the orderBrowse Collection has the query
select e from Order e
whenever I open OrderBrowse it gives me this error
and we believe it is because “order” is a reserved word
previously we used a prefix before using the class name "
select e from projectName_Order e
how can I reach the entity now without it clashing on to reserved words, without changing my entity names?
thank you
albudarov
(Alexander Budarov)
June 15, 2021, 7:37am
2
Hi,
You cannot use reserved words in the JPQL.
Therefore you need to change entity name for the Order entity, e.g. to “Order_”:
@JmixEntity
@Table(name = "ORDER_")
@Entity(name = "Order_")
public class Order {
Jmix Studio 1.0.0 will create entity declaration like I’ve shown above.
arturoams
(Arturo Martínez)
June 15, 2021, 2:45pm
3
thank you that is what is assumed, is there no other way to acces it, even by adressing the whola package?
com.project.projectname.Order?
albudarov
(Alexander Budarov)
June 16, 2021, 7:19am
4
I think that it is a bad idea to try to escape the problem which can be solved in one minute, by changing entity name.
To have an entity name that is a reserved JPQL word - should be avoided.
2 Likes
arturoams
(Arturo Martínez)
June 16, 2021, 4:17pm
5
Yes I opted for refactoring a huge chunk of the app, because “order” was an important entity that had lots of other entities depending on it, also containing the word “order” in some capacity. That was the part that I was trying to avoid.
Thank you for your help!
albudarov
(Alexander Budarov)
June 17, 2021, 6:28am
6
You don’t need to refactor your code (I assume you mean renaming your class).
The name used in the JPQL is not class name. It’s the “name” parameter of the @Entity annotation.
So if you have the code:
@Entity(name = "Foo")
public class Bar {
Then the entity name in JPQL queries will be select e from Foo, not Bar.