glassfish
  1. glassfish
  2. GLASSFISH-19308

Hibernate 3.5.0-02 installed by Update Center has a JPA 2 bug

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.1.2
    • Fix Version/s: None
    • Component/s: update_center
    • Labels:
      None

      Description

      JPA 2 criteria API is broken in Hibernate 3.5.0-02, which is the version of Hibernate EM installed by GlassFish Update Center:

      https://hibernate.onjira.com/browse/HHH-5051

      This issue was fixed in 3.5.1.Final.

      To understand the problem, consider this code:

      CriteriaBuilder cb = em.getCriteriaBuilder();
      CriteriaQuery<Event> criteria = cb.createQuery(Event.class);
      Root<Event> event = criteria.from(Event.class);
      criteria.select(event);
      criteria.where(cb.equal(event.get(Event_.eventType), eventType));
      TypedQuery<Event> query = em.createQuery(criteria);
      return query.getResultList();

      Hibernate generates the following invalid SQL:

      select event0_.id as id6_, event0_.version as version6_, event0_.created_by as created8_6_, event0_.description as descript3_6_, event0_.end_date as end4_6_, event0_.event_type as event5_6_, event0_.start_date as start6_6_, event0_.title as title6_, event0_.venue as venue6_ from event event0_ inner join venue venue1_ on event0_.venue=venue1_.id where 1=1 and event0_.event_type=_binary'??\0^E~r\0^]com.mycompany.model.EventType\0\0\0\0\0\0\0\0^R\0\0xr\0^Njava.lang.Enum\0\0\0\0\0\0\0\0^R\0\0xpt\0^EMOVIE'

      Workaround:

      • Do not install Hibernate EM using the GlassFish Update Center
      • Add the following to pom.xml if using Maven:

      <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-entitymanager</artifactId>
      <version>3.5.1-Final</version>
      </dependency>
      <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>1.5.8</version>
      </dependency>
      <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <version>1.0.0.GA</version>
      </dependency>
      <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-validator</artifactId>
      <version>4.0.2.GA</version>
      </dependency>

      • Deploy the application. It will use the bundled Hibernate jars instead of the GlassFish JPA implementation.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Snjezana Sevo-Zenzerovic
            Reporter:
            Ian Hlavats
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: