Skip to main content



      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 15:51 Go to next message
Eclipse UserFriend
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 16:17] by Moderator

Re: Eclipselink JPA named query not ignoring white spaces. [message #894864 is a reply to message #894859] Tue, 10 July 2012 16:22 Go to previous messageGo to next message
Eclipse UserFriend
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 16:25 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 16:37:01 EDT 2025

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

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

Back to the top