boolean « Query « JPA Q&A





1. How to get sum(boolean) as integer in hibernate's criteria query?    stackoverflow.com

In a simple 'vote up / vote down' scenario , I want to sum the total 'up' count .

criteria.add(Restrictions.eq("vote" , Boolean.TRUE));
criteria.setProjection(Projections.rowCount());
The generated SQL is sum(this_.vote) as y1_ and generates ...

2. Need to aggregate boolean type column value in hibernate    stackoverflow.com

I have a table with one of the column as boolean type and I need use group by projection on another column. Now I want all the columns in select list. ...

3. JPA: TRUE, order by boolean, outer join...    java.net

1, While creating EJBQL queries algorithmically, I tried to use "TRUE" as the null-clause in the WHERE part of the query to conjunct other clauses to, if any. But this is what I get: Exception [TOPLINK-8025] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.EJBQLException Exception Description: Syntax error parsing the query [SELECT COUNT (e) FROM FileMetaInfo e WHERE TRUE ], ...

4. Migration woes - Cannot find data type boolean    forum.hibernate.org

Hello, What has changed regarding the boolean data type between Hibernate 3.1.3 and Hibernate 4? I am in the process of migrating an application and I am running into the following error: 16:21:04,368 INFO [stdout] (Thread-25) 16:21:04,368 INFO [stdout] (Thread-25) create table Example ( 16:21:04,368 INFO [stdout] (Thread-25) theId varchar(255) not null, 16:21:04,368 INFO [stdout] (Thread-25) name varchar(255) null, 16:21:04,368 INFO ...

5. Query on a boolean?    forum.hibernate.org

What's the proper way to query on a boolean (yes_no) field? The property in my class is type boolean (not Boolean). The mapping type is "yes_no". The query I want to write is something like: session.find("from Question as q where q.isActive = true") 'true' in this query is an invalid identifier. Thanks!

6. Problem with HQL query regarding Booleans    forum.hibernate.org

Can anyone tell me whats wrong with the following HQL? FROM test.UserOTK AS otk WHERE (otk.name = 'email' OR otk.name = 'xmpp') AND NOT otk.used otk.used is a Boolean and if I leave out "AND NOT otk.used", it works. Here is the Exception I get: Incorrect query syntax [FROM test.UserOTK AS otk WHERE (otk.name = 'email' OR otk.name = 'xmpp') AND ...

7. how do I do a boolean and() query?    forum.hibernate.org

egervari wrote: I have a one-to-many association from table A to B. B has a boolean field called is_accessed. I'd like to write a query that gives me all the A's where all it's own B's are true (or false), but I'm having a real hard time doing this. I have two tables: Department and Employee with a one-to-many from Department ...

8. HQL count for a boolean result    forum.hibernate.org

9. Generated query including boolean types    forum.hibernate.org

I'm having issues with Criteria queries. My query call looks like... DetachedCriteria criteria = DetachedCriteria.forClass(instance.getClass()) .add(Example.create(instance)); List results = getHibernateTemplate().findByCriteria(criteria); My instance class has these fields... private Integer issueId; private Contact supplier; private IssueComponent issueComponent; private Product product; private Contact ownerContact; private String shortDesc; private String longDesc; private String fileName; private String status; private String criticality; private String resolution; private String ...





10. HSQLDialect and Booleans in native queries    forum.hibernate.org

public class HSQLDialect_HHH_1598 extends org.hibernate.dialect.HSQLDialect { public HSQLDialect_HHH_1598() { super(); registerColumnType(Types.BIT, "boolean"); // Assert that the new type is registered correctly. if (!"boolean".equals(getTypeName(Types.BIT))) { ...

11. Are boolean literals in where clause supported?    forum.hibernate.org

Hibernate version: 3.3.0 GA Full stack trace of any exception that occurs: org.hibernate.QueryException: Unable to render boolean literal value [SELECT COUNT(item) FROM org.example.runtime.impl.repository.db.jpa.DbItem item WHERE ( NOT (item.deleted = TRUE) ) AND ( item.application IS NULL ) AND ( item.owner = :owner ) AND ( ( (:searchService = TRUE) AND (item.itemType = 'SERVICE') ) OR ( (:searchApplication = TRUE) AND (item.itemType ...

12. UNION concept, multi-boolean queries    forum.hibernate.org

General question from the HQL/JPA-QL perspective -- If you write a JPA-QL query such as the following with multi-boolean where clause (note, this is an example for simplicity to show boolean query, not to be used to 'solve' the problem with hibernate search): SELECT o from MyObject o WHERE (o.firstname = 'jon' OR o.firstname='john') AND (o.lastname = 'smith' OR o.lastname='smithe') With ...