|Eclipselink JPA named query not ignoring white spaces. [message #894859]
||Tue, 10 July 2012 19:51
| Chandra Narasimha
Registered: July 2012
I am using JPA2.0 Eclipselink 2.3.2. I have database field CHAR(12) mapped in entity as a String. I have named query to retrieve entity by passing primary key input parameter.
In database value stored only with two characters and remaining are spaces because it is CHAR(12).
Example Table X column id (CHAR12) value "IS "
Named query looks like this
@NamedQuery(name = "getById",
query = "SELECT sec " +
" FROM TABLE ref " +
" WHERE ref.id = :idValue "
list = em.createNamedQuery("getById ")
.setParameter("idValue ", "IS")
I am passing parameter string value as a "IS" to the named query but my named query is not returning any list. If I pass with white spaces "IS " it is retrieving.
I don't want to pad with spaces, I would like to pass only "IS". Even I don't want to use Oracle trim function in my named query. trim (training from t.id) -- I don't want to use this (I know it works with this option)
If I execute sql query in database it works fine. Select * from Table where id = 'IS'; - it shows the rows
Why named query not retrieving the results, how to indicate namedquery to ignore char spaces while executing query?
How to get the result from naedquery without using these two above options. Could someone please help me with this issue?
[Updated on: Tue, 10 July 2012 20:17]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.02223 seconds