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 7538679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:10:56+00:00 2026-05-30T07:10:56+00:00

I am working in Grails. I am writing a code that deletes the account

  • 0

I am working in Grails. I am writing a code that deletes the account of a particular logged in user once he has clicked on the Delete link. Now this is my code found in my controller,

def delete = {
   def account = springSecurityService.getCurrentUser()
   def registrant = Registrant.findByAccount(account)
   def loggeduser = registrant.account.username

   RegistrantEligibilityInformation.executeUpdate("delete RegistrantEligibilityInformation as rei where rei.registrant in (select reg from Registrant as reg where reg.account.username in(:loggeduser))",[loggeduser:loggeduser])
   RegistrantEducationInformation.executeUpdate("delete RegistrantEducationInformation as reduc where reduc.registrant in (select reg from Registrant as reg where reg.account.username in(:loggeduser))",[loggeduser:loggeduser])
   Registrant.executeUpdate("delete Registrant as reg where reg.account.username in(:loggeduser)",[loggeduser:loggeduser])
   AccountRole.executeUpdate("delete AccountRole as actrole where actrole.account.username in(:loggeduser)",[loggeduser:loggeduser])
   Account.executeUpdate("delete Account as act where  act.username in(:loggeduser)",[loggeduser:loggeduser])               

   toolsService.deletion(registrant)
}

I have five domain classes here which are the RegistrantEligibilityInformation, RegistrantEducationInformation, Registrant, AccountRole, and Account. Everytime I run my program, I got an error message like this:

URI: /user/profile/delete
Class: org.postgresql.util.PSQLException
Message: ERROR: column reference "id" is ambiguous Position: 49

…which pertains to this code:

RegistrantEligibilityInformation.executeUpdate("delete RegistrantEligibilityInformation as rei where rei.registrant in (select reg from Registrant as reg where reg.account.username in(:loggeduser))",[loggeduser:loggeduser])

…and I think to the rest of my codes too. I don’t know what to do, as I am still new to Grails.

  • 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-05-30T07:10:57+00:00Added an answer on May 30, 2026 at 7:10 am

    Use in when you have a collection of items, not a single one – use = when it must match. So in makes sense for the subqueries, but not the loggeduser matches.

    I’m not sure why Hibernate doesn’t support the subquery you’re using, but it works if you match on the id instead of the whole object:

    RegistrantEligibilityInformation.executeUpdate(
       "delete RegistrantEligibilityInformation as rei where rei.registrant.id in (" +
       "select reg.id from Registrant as reg where reg.account.username=:loggeduser)",
       [loggeduser:loggeduser])
    
    RegistrantEducationInformation.executeUpdate(
       "delete RegistrantEducationInformation as reduc where reduc.registrant.id in (" +
       "select reg.id from Registrant as reg where reg.account.username=:loggeduser)",
       [loggeduser:loggeduser])
    
    Registrant.executeUpdate(
       "delete Registrant as reg where reg.account.username=:loggeduser",
       [loggeduser:loggeduser])
    
    AccountRole.executeUpdate(
       "delete AccountRole as actrole where actrole.account.username=:loggeduser)",
       [loggeduser:loggeduser])
    
    Account.executeUpdate(
       "delete Account as act where act.username=:loggeduser)",
       [loggeduser:loggeduser])               
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with grails. I have created a service that will delete the
I am working on a Grails project that has a transitive dependency on mx4j
I'm working on a Grails 1.0.4 project that has to be released in less
I am working in a previously existing grails project that has some search functionality
I'm working through the Grails In Action book and have noticed 2 instances that
I'm working through the Grails in Action book, and I'm stuck at that part
I'm working on a Grails web app that would be similar in access patterns
I'm working on a grails legacy project. A domain class called User exists. It
I've an basic app that working fine when i'm runngin it with grails run-app
I am working with groovy/grails technology, in that from one of the action called

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.