Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8136589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:48:28+00:00 2026-06-06T10:48:28+00:00

I am currently working on a grails project where I need to execute a

  • 0

I am currently working on a grails project where I need to execute a hibernate query. Everytime I run my code with existing data on my database, everything works fine. But if I run it with my database empty, I got an error thrown.

This is my code:

    def actActivation = AuditLog.executeQuery("select ll.username from AuditLog ll where ll.event = ? ",[AuditLogEvent.ACCOUNT_ACTIVATION])
    def actDeleted = AuditLog.executeQuery("select ll.username from AuditLog ll where ll.event = ? ",[AuditLogEvent.ACCOUNT_DELETION])
    def actPurged = AuditLog.executeQuery("select ll.username from AuditLog ll where ll.event = ? ",[AuditLogEvent.ACCOUNT_PURGING])
    def list = AuditLog.executeQuery("""select sum(case when l.details like '%Gender: Male.%' and l.event = :actActivationEvent then 1 else 0 end),
            sum(case when  l.details like '%Gender: Female.%' and l.event = :actActivationEvent then 1 else 0 end),
            sum(case when  l.event = :actActivationEvent then 1 else 0 end),
            sum(case when  l.details like '%Gender: Male.%' and l.event = :actFinishRegEvent and ((l.username not in(:actActivation)) or (l.username in(:actDeleted) or l.username in(:actPurged))) then 1 else 0 end),
            sum(case when  l.details like '%Gender: Female.%' and l.event = :actFinishRegEvent and ((l.username not in(:actActivation)) or (l.username in(:actDeleted) or l.username in(:actPurged))) then 1 else 0 end),
            sum(case when  l.event = :actFinishRegEvent and ((l.username not in(:actActivation)) or (l.username in(:actDeleted) or l.username in(:actPurged))) then 1 else 0 end),
            sum(case when  l.details like '%Gender: Male.%' and l.event = :actDeletionEvent then 1 else 0 end),
            sum(case when  l.details like '%Gender: Female.%' and l.event = :actDeletionEvent then 1 else 0 end),
            sum(case when  l.event = :actDeletionEvent then 1 else 0 end),
            sum(case when  l.details like '%Gender: Male.%' and l.event = :actPurgedEvent then 1 else 0 end),
            sum(case when  l.details like '%Gender: Female.%' and l.event = :actPurgedEvent then 1 else 0 end),
            sum(case when  l.event = :actPurgedEvent then 1 else 0 end)                
        from AuditLog l
        where l.dateCreated >= :startDate and l.dateCreated < :endDate""",
        [
            actActivationEvent:AuditLogEvent.ACCOUNT_ACTIVATION,
            actDeletionEvent:AuditLogEvent.ACCOUNT_DELETION,
            actPurgedEvent:AuditLogEvent.ACCOUNT_PURGING,
            actFinishRegEvent:AuditLogEvent.FINISH_REGISTRATION,
            actActivation:actActivation,
            actDeleted:actDeleted,
            actPurged:actPurged, 
            startDate: startDate,
            endDate:endDate
        ])

This is the error message when I execute the code with the database empty.

Class: org.hibernate.hql.ast.QuerySyntaxException

Message:

unexpected end of subtree [select sum(case when l.details like ‘%Gender: Male.%’ and l.event = :actActivationEvent then 1 else 0 end), sum(case when l.details like ‘%Gender: Female.%’ and l.event = :actActivationEvent then 1 else 0 end), sum(case when l.event = :actActivationEvent then 1 else 0 end), sum(case when l.details like ‘%Gender: Male.%’ and l.event = :actFinishRegEvent and ((l.username not in()) or (l.username in() or l.username in())) then 1 else 0 end), sum(case when l.details like ‘%Gender: Female.%’ and l.event = :actFinishRegEvent and ((l.username not in()) or (l.username in() or l.username in())) then 1 else 0 end), sum(case when l.event = :actFinishRegEvent and ((l.username not in()) or (l.username in() or l.username in())) then 1 else 0 end), sum(case when l.details like ‘%Gender: Male.%’ and l.event = :actDeletionEvent then 1 else 0 end), sum(case when l.details like ‘%Gender: Female.%’ and l.event = :actDeletionEvent then 1 else 0 end), sum(case when l.event = :actDeletionEvent then 1 else 0 end), sum(case when l.details like ‘%Gender: Male.%’ and l.event = :actPurgedEvent then 1 else 0 end), sum(case when l.details like ‘%Gender: Female.%’ and l.event = :actPurgedEvent then 1 else 0 end), sum(case when l.event = :actPurgedEvent then 1 else 0 end) from ph.gov.csc.comex.log.AuditLog l where l.dateCreated >= :startDate and l.dateCreated < :endDate]

How will I resolve this? Help please! Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T10:48:31+00:00Added an answer on June 6, 2026 at 10:48 am

    The problem comes from the fact that you blindly pass the result of the three first queries as arguments to the last query. This results in a where clause containing:

    where ... l.username not in () ...
    

    which is invalid. An in () clause must at least have one element inside the parentheses. You should use another query if one of the list you pass as argument to the in clauses is empty.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on a project using netbeans 6.9 and grails 1.3. I'm trying
Im currently working on a project that requires the following. I need to be
Currently working on database part of android project. The main aim of the project
Currently working on a project in MVC-3. Trying to put the following code in
Iam currently working on a iPad project where i build my code on top
Currently working on a project where we need to drop in various static html
I am currently working on grails project. I have created eight different plugins. Each
I am now currently working on a grails project . I have a problem
I'm a newbie on grails. I am now currently working on my scaffolding templates
We have an application in Grails 2.0 that we have working when we run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.