Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] LIKE expression with enum

For the enum issue, please log a bug for this, even if the JPA spec JPQL does
not allow this, EclipseLink should still be able to do this.  You should be
able to use an Expression criteria query for this.

For the native SQL issue, I would always recommend defining all your column
names in upper-case to avoid case sensitivity issues on different databases. 
If you are unable to do this EclipseLink also has a persistence.xml
property,

"eclipselink.jdbc.uppercase-columns"="true"

That should resolve the issue.



cmathrusse wrote:
> 
> The issue that I am having is that we would like to perform a SELECT
> object(o) FROM ResourceDefinition WHERE id LIKE :param
> <BR />
> The problem is that we cannot supply a string for the param as the the
> param would be a String and the id is an enum. 
> <BR />
> <BR />
> 
> So it seemed to me that the easiest way around this issue was to write a
> NativeQuery. 
> SELECT * FROM resource_definition WHERE id LIKE ?1
> <BR />
> <BR />
> 
> But this produced the following exception:
> Local Exception Stack: 
> <BR />
> <BR />
> <CODE>
> Exception [EclipseLink-6044] (Eclipse Persistence Services - 1.1.0.r3634):
> org.eclipse.persistence.exceptions.QueryException
> 
> Exception Description: The primary key read from the row [DatabaseRecord(
> <BR /><BR />
> 	 => ORD_001
> <BR /><BR />
> 	 => Order Number: [{0}], Process: [{1}] has been updated to 'PENDING'
> <BR /><BR />
> 	 => 2008-12-01 00:00:00.0
> <BR /><BR />
> 	 => 2008-12-01 00:00:00.0
> <BR /><BR />
> 	 => 1
> <BR /><BR />
> 	 => INFO)] during the execution of the query was detected to be null. 
> Primary keys must not contain null.
> <BR /><BR />
> Query: ReadAllQuery(name="ResourceDefinition.findMatchingResources"
> referenceClass=ResourceDefinition sql="SELECT * FROM resource_definition
> WHERE id LIKE ?")
> </CODE>
> <BR />
> <BR />
> 
> 
> Searching the internet I found that this is caused by a mismatch between
> the column names returned in the resultSet vs. those defined on the class.
> Currently we are developing using a JavaDB on our local machines, but when
> we go into Test and Production it will be Sybase ASE. I didn't think this
> would be an issue but as I have discovered, with JavaDB, EclipseLink
> generates the DDL with unquoted table and column names. This results in
> tables and columns being defined in uppercase. With Sybase ASE, unquoted
> table and column names are defined in lowercase.
> <BR />
> <BR />
> 
> So, a simply LIKE expression has caused me a good amount of grief. Do you
> have any suggestions as to how I can get around these issues?
> <BR />
> <BR />
> 
> Thanks for the help.
> 
> 
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/LIKE-expression-with-enum-tp23336881p23370264.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top