Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dali » Eclipselink JPA named query not ignoring white spaces.(Eclipselink JPA named query not ignoring white spaces.)
Eclipselink JPA named query not ignoring white spaces. [message #894859] Tue, 10 July 2012 19:51 Go to next message
Chandra Narasimha is currently offline Chandra NarasimhaFriend
Messages: 5
Registered: July 2012
Junior Member
Hi,

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

@NamedQueries({
@NamedQuery(name = "getById",
query = "SELECT sec " +
" FROM TABLE ref " +
" WHERE ref.id = :idValue "
)
})

list = em.createNamedQuery("getById ")
.setParameter("idValue ", "IS")
.getResultList();

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?

Thanks

[Updated on: Tue, 10 July 2012 20:17]

Report message to a moderator

Re: Eclipselink JPA named query not ignoring white spaces. [message #894864 is a reply to message #894859] Tue, 10 July 2012 20:22 Go to previous messageGo to next message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 475
Registered: July 2009
Senior Member
Hi...This question would likely get a quicker response on the EclipseLink Forum. Please repost here -> www.eclipse.org/forums/eclipse.rt.eclipselink.

Neil
Re: Eclipselink JPA named query not ignoring white spaces. [message #894867 is a reply to message #894864] Tue, 10 July 2012 20:25 Go to previous message
Chandra Narasimha is currently offline Chandra NarasimhaFriend
Messages: 5
Registered: July 2012
Junior Member
I posted in www.eclipse.org/forums/eclipse.rt.eclipselink.

Thanks
Previous Topic:Dali 3.2 released as part of Eclipse Juno!
Next Topic:what is the relationship between Dali and EclipseLink
Goto Forum:
  


Current Time: Tue Mar 19 07:23:07 GMT 2024

Powered by FUDForum. Page generated in 0.02179 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top