openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From it-media.k...@daimler.com
Subject @Enumerated(EnumType.ORDINAL) in JPQL CASE WHEN generates invalid SQL using name of Enumeration member, not ordinal
Date Wed, 10 Oct 2012 09:18:15 GMT
Hello,

I've come across an issue with a column used within a JQPL CASE WHEN 
Selection.

The column's definition is as follows:

    @Column(name = "GEN_STATUS")
    @Enumerated(EnumType.ORDINAL)
    private ApprovalState state;

The JPQL used here is

SELECT c, 
        ( CASE c.approval.state 
                WHEN model.protocol.ApprovalState.IN_PROCESS THEN 1 
                WHEN model.protocol.ApprovalState.RELATION_CHECK THEN 2
                WHEN model.protocol.ApprovalState.IN_APPROVAL THEN 3
                WHEN model.protocol.ApprovalState.NEEDS_SCORING THEN 4
                WHEN 
model.protocol.ApprovalState.ADOPTION_REQUEST_IN_PROCESS THEN 5
                WHEN model.protocol.ApprovalState.ADOPTION_REQUESTED THEN 
6
                WHEN model.protocol.ApprovalState.APPROVED THEN 7
                WHEN 
model.protocol.ApprovalState.APPROVED_WITH_COLLATERALS THEN 8
                WHEN model.protocol.ApprovalState.ACTIVATED THEN 9
                WHEN model.protocol.ApprovalState.CANCELLED THEN 10
                WHEN model.protocol.ApprovalState.DECLINED THEN 11
                WHEN model.protocol.ApprovalState.CREATED THEN 12
                WHEN model.protocol.ApprovalState.DEDUCTED THEN 13
                WHEN model.protocol.ApprovalState.DELETED THEN 14
                WHEN model.protocol.ApprovalState.PROPOSAL_CANCELLED THEN 
15
                ELSE 0
          END ) AS vehicleStateOrder 
FROM DbContract c WHERE c.person.personId = :personId 
ORDER BY vehicleStateOrder, c.insertDate

However, when this JPQL is transferred to SQL, e.g. ORACLE in this case 
throws the following error:

ORA-00932: Inkonsistente Datentypen: NUMBER erwartet, CHAR erhalten

A relevant part of the query is:

SELECT * FROM (SELECT t0.VTR_ID AS c0,  CASE t2.GEN_STATUS WHEN 
'IN_PROCESS' THEN 1 WHEN 'RELATION_CHECK' THEN 2 WHEN 'IN_APPROVAL' ...

The problem here is, that as the column definition denotes, not the 
ordinal number, but the enumeration name is used. 

Wer are using WebSphere 8.0.0.4 which includes 
openjpa-2.1.2-SNAPSHOT-r422266:1333100.

Can somebody please tell me, what we can do to get this query working or 
is this a bug in the JPQL parsing system?

Best regards,

Heiko

--
Dr.-Ing. Heiko Kopp / Fa. Vision iT media GmbH

If you are not the intended addressee, please inform us immediately that you have received
this e-mail in error, and delete it. We thank you for your cooperation.  
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message