First, please file a usability bug for the JPQL parameter issue.
Second, setting the persistence unit property
"eclipselink.jdbc.uppercase-columns" = "true" should resolve your
native SQL issue.
--Gordon
cmathrusse wrote:
A
simple problem has caused me a great deal of time. I've got an entity
as follows:
public class ResourceDefinition implements Serializable {
@Column( name = "content", nullable = false )
private String content;
@Column( name = "create_date", nullable = false )
@Temporal( javax.persistence.TemporalType.TIMESTAMP )
private java.util.Calendar createDate;
@Id
@Enumerated(EnumType.STRING)
@Column( name = "id", length = 10)
private ResourceKey id;
@Column( name = "mod_date", nullable = false )
@Temporal( javax.persistence.TemporalType.TIMESTAMP )
private java.util.Calendar modDate;
@ManyToOne
@JoinColumn(name = "severity", nullable = false)
private Severity severity;
@Column( name = "version", nullable = false )
@Version
private int version;
The Primary Key, ResourceKey, is a simple enum:
public enum ResourceKey { ADR_001, ....
}
The issue that I am having is that we would like to perform a SELECT
object(o) FROM ResourceDefinition WHERE id LIKE :param
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.
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
But this produced the following exception:
Local Exception Stack:
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(
=> ORD_001
=> Order Number: [{0}], Process: [{1}] has been updated to 'PENDING'
=> 2008-12-01 00:00:00.0
=> 2008-12-01 00:00:00.0
=> 1
=> INFO)] during the execution of the query was detected to be null.
Primary keys must not contain null.
Query: ReadAllQuery(name="ResourceDefinition.findMatchingResources"
referenceClass=ResourceDefinition sql="SELECT * FROM
resource_definition WHERE id LIKE ?")
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.
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?
Thanks for the help.
View this message in context: LIKE
_expression_ with enum
Sent from the EclipseLink
- Users mailing list archive at Nabble.com.
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
|