How can I cast a Integer to a String in EJBQL
ejbql
Solution
Since EJB3 EJBQL has been (almost) replaced by JPQL. In EJBQL and according to http://docs.oracle.com/cd/E11035_01/kodo41/full/html/ejb3_langref.html in JPQL as well there is no functionality to CAST a property of an entity.
So like I already told there are two options left:
- Use a native Query.
- Add special cast methods to the entities.
Problem
I got a Entity with a Integer ``` @Entity(name=customer) public Customer { ... @Column private int number; ... //getter,setter } ``` Now I want to cast this Integer in a query to compare it with an other value. I tried this Query: ``` "SELECT c FROM customer c WHERE CAST(c.number AS TEXT) LIKE '1%'" ``` But it doesn't work.