enum « Query « JPA Q&A





1. Querying collections of value type in the Criteria API in Hibernate    stackoverflow.com

In my database, I have an entity table (let's call it Entity). Each entity can have a number of entity types, and the set of entity types is static. Therefore, there ...

2. Hibernate Projections.sum() over an enum    stackoverflow.com

I need some help with Hibernate Projections. I have a class called Activity with a property "duration" which is an Enum. Duration is a Integer field on the Oracle Database. I ...

3. Control sort order of Hibernate EnumType.STRING properties    stackoverflow.com

Currently, my project uses @Enumerated(EnumType.ORDINAL), so when I sort by this column, it is ordering based on the order in the enum, which works fine. But I need to add some ...

4. Java JPA "Error compiling the query" when it uses an enum    stackoverflow.com

The following JPA query doesn't compile:

@NamedQuery(name = "PSA.findBySourceSystem", 
    query = "SELECT p FROM PSA p WHERE p.sourceSystem.id = :sourceSystemId")
p.sourceSystem is the following enum:
public enum SourceSystem {
  ...

5. HQL query with enums    stackoverflow.com

I'm trying to make this query work, in my model Workshop I have a enum type field where it connects to roles. I kinda have never used HQL to do this, ...

6. Using Enum in Hibernate causes select followed by an update statement    stackoverflow.com

I have a mapped entity wich has an enum property. By loking at log file, whenever I run a select statement on such entity, the result is an immediately following update. For example ...

7. Using enum parameters in Criteria query    stackoverflow.com

If I have an enum field in my persisted class, mapped to DB by either ordinal or string, how do I set a criteria param on it? This doesn't work:

public static ...

8. Play! JPA - Get an enum value in a query    stackoverflow.com

This is my enum :

package enums;

public enum SessionType {
    SESSION_NORMAL(12), SESSION_PERFECT(5), SESSION_SOLO(1);

    private int value;

    private SessionType(int value) {
    ...

9. Hibernate queries on a set of enums    stackoverflow.com

Today I defined an entity containing a set of enums. Instead of a oneToMany collection, I used a CollectionOfElements since I wanted to reference the Java enums directly rather than wrappers. The ...





10. Problems with making a query when using Enum in entity    stackoverflow.com

I have the following in a Question entity:

@NamedQuery(name = "Question.allApproved", query = "SELECT q FROM Question q WHERE q.status = 'APPROVED'")
and
@Enumerated(EnumType.STRING)
private Status status;

public Status getStatus() {
    return status;
}

public ...

12. Enum parameter to Query    forum.hibernate.org

13. Hibernate queries on a set of enums    forum.hibernate.org

Hi all, I have posted this question on StackOverflow as well, I hope this "double post" is not a problem for you. Today I defined an entity containing a set of enums. Instead of a oneToMany collection, I used a CollectionOfElements since I wanted to reference the Java enums directly rather than wrappers. The class (including Hibernate annotations) looks like: Code: ...

14. Is it possible to use enum in HQL query    forum.hibernate.org

Hibernate version: 3.1.3 Hibernate Annoations 3.1 beta9 I have properties defined on an enumerated type. Is it possible to use an enum in an HQL query? The enum in question is a lookup table and is references, via @Enumerated, by mapped entities. Enumerated type definition... Code: public enum ComponentType { GLOBAL(1,"Global","Global"), ... other enum types ...

15. JBoss jBPM & Hibernate: storing Enums, querying with HBN    forum.hibernate.org

Newbie Joined: Fri May 12, 2006 10:37 am Posts: 2 I am using JBoss jBPM and storing a java 1.5 enum in a JBPM StringInstance (subclass of VariableInstance, see mapping below). To do this, JBPM recommends creating a Converter which basically has a convert() and revert() method. This appears to work fine for creating & retrieving TaskInstances through JBPM, but sometimes ...

16. How to query for enum-types? (working, but ugly?)    forum.hibernate.org

Hibernate 3.2, Java 5 (or even 6) ---- I'm just in the process of converting some of our ugly "public static final int"-constants into nice and clean "enums" (Java 5). It was nice to see this work (almost) immediately with Hibernate (annotations). :-) However, I have a "real problem" with our queries. The "old version" for a very very simple one ...





17. HQL for querying a column represented by a Java 5 enum    forum.hibernate.org

String hql = "from FoobarDTO " + "where projectId = :parentId " + "and alphaId = :alphaId " + "and kind = :kind and deleteStatus = 0"; Query query = HibernateUtil.getCurrentSession().createQuery(hql); query.setString("alphaId", alphaId); query.setInteger("parentId", parentId); query.setEntity("kind", kind); ...