| Summary: | Annotation EnumType.String ignored in CriteriaBuilder.selectCase query resulting in SQLSyntaxErrorException | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Anatol Mising name <bugzilla> | ||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||
| Status: | CLOSED WORKSFORME | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P2 | CC: | andrei.ilitchev, hamud.alhammoud, tom.ware | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| URL: | http://www.eclipse.org/forums/index.php/t/261302/ | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 206217 [details]
Testcase - Run JUnit Test X1EnumEntityTest
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next. I am temporarily targetting for 2.3.2. 2.3.2 is going to ship shortly and the likely actual target is 2.3.3. Correcting target milestone to next milestone that will include community-submitted bugs. The test passed with 2.3.3: [EL Finer]: Connection(17938704)--begin transaction [EL Fine]: Connection(17938704)--INSERT INTO X1ENUMENTITY (ID, X1) VALUES (?, ?) bind => [0, GREEN] [EL Finest]: Execute query InsertObjectQuery(EclipseLinkEnumTest.X1EnumEntity@648016) [EL Fine]: Connection(17938704)--INSERT INTO X1ENUMENTITY (ID, X1) VALUES (?, ?) bind => [1, GREEN] [EL Finer]: end unit of work flush [EL Finer]: resume unit of work [EL Finer]: initialize identitymaps [EL Finer]: begin unit of work flush [EL Finer]: end unit of work flush [EL Finest]: Execute query ReportQuery(referenceClass=X1EnumEntity ) [EL Fine]: Connection(17938704)--SELECT CASE WHEN (X1 = ?) THEN ? ELSE ? END FROM X1ENUMENTITY bind => [GREEN, 1, 0] [EL Finer]: begin unit of work commit [EL Finer]: Connection(17938704)--commit transaction // I've added this [EL Finest]: Connection(17938704)--Connection released to connection pool [default]. [EL Finer]: end unit of work commit [EL Finer]: resume unit of work The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Build Identifier: 20100617-1415 Using EclipseLink 2.3.0 I get the following SQLSyntaxException, using EclipseLink 2.1.3 it works fine. Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLSyntaxErrorException: Comparisons between 'VARCHAR (UCS_BASIC)' and 'INTEGER' are not supported. Types must be comparable. [...] The respective call looks like this. CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<X1EnumEntity[]> query = cb.createQuery(X1EnumEntity[].class); Root<X1EnumEntity> from = query.from(X1EnumEntity.class); Expression<Object> isLoaded = cb.selectCase().when(cb.equal(from.get("x1"), X1Enum.GREEN), Long.valueOf(1)).otherwise(Long.valueOf(0)); query.multiselect(isLoaded); em.createQuery(query).getResultList(); The generated SQL statement is EclipseLink 2.3.0: SELECT CASE WHEN (X1 = 0) THEN 1 ELSE 0 END FROM X1ENUMENTITY EclipseLink 2.1.3: SELECT CASE WHEN (X1 = GREEN) THEN 1 ELSE 0 END FROM X1ENUMENTITY The Entity field X1EnumEntity.x1 is annotated as follows @Column @Enumerated(EnumType.STRING) private X1Enum x1; Reproducible: Always Steps to Reproduce: 1. Use EclipseLink 2.3.0 2. Persist entity with Enum field annotated @Enumerated(EnumType.String) 3. Build selectCase query using CriteriaBuilder matching content of enum column with enum value 4. Execute query