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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:47:43+00:00 2026-06-13T13:47:43+00:00

Problem is with the following query. I want to list all the LI:s in

  • 0

Problem is with the following query. I want to list all the LI:s in L that contain an I with id ‘I01’.

query:

def c = L.withCriteria {
  lis {
    i {                   
      eq("id","I01")                                 
    }
  }
}

Column “I_ALIAS2X2_.ID” not found; SQL statement: select this_.id as
id4_1_, this_.version as version4_1_, lis_alias1x1_.i_id as i1_7_0_,
lis_alias1x1_.l_id as l2_7_0_, lis_alias1x1_.version as version7_0_
from l this_ inner join LI lis_alias1x1_ on
this_.id=lis_alias1x1_.l_id where ((i_alias2x2_.id=?)) [42122-164]

Is there something wrong in my criteria or are my domains not correct ? If I add ‘long id’ into LI domain and comment out the ‘id: composite…’ row then criteria runs ok.

domains:

class L {
long id   
//can this hasMany be used here ? domain L is the other FK in LI domain
static hasMany = [lis: LI]

static mapping = {       
    lis: joinTable: false       
}

static constraints = {
}
}

import org.apache.commons.lang.builder.HashCodeBuilder

class LI implements Serializable {
//domain has only FK:s to L and I

static belongsTo = [l: L, i: I]

static mapping= {
    table "LI"
    id composite:['i', 'l']
    i column: 'i_id'
    l column: 'l_id'       
}

static constraints = {
}

boolean equals(other) {        
    if (!(other instanceof LI)) { return false }       
    other.l == l && other.i == i       
}

int hashCode() {        
    def builder = new HashCodeBuilder()
    builder.append l
    builder.append i
    builder.toHashCode()            
}
}

class I {
String id       
static mapping = {   
    table "I"       
    id generator:'assigned'
    version: false   
}   
static constraints = {
}
}

bootstrap:

    I ii = new I(id:"I01").save(flush:true)           
    I ii2 = new I(id:"I02").save(flush:true)

    L l = new L().save(flush:true);           
    L l2 = new L().save(flush:true);       

    LI li = new LI(l:l,i:ii).save(flush:true)       
    LI li2 = new LI(l:l2, i:ii2).save(flush:true)

schema:

create table I (id varchar(255) not null, version bigint not null, d varchar(255) not null, primary key (id));
create table LI (i_id varchar(255) not null, l_id bigint not null, version bigint not null, primary key (i_id, l_id));
alter table LI add constraint FK97D312CFA foreign key (i_id) references I;
alter table LI add constraint FK97D328A1A foreign key (l_id) references l;

EDIT:

Sérgio’s solution works but if you have domain I defined like this:

class I {
String id

static belongsTo=[A:a] //has only 'string id' column

static mapping = {   
    table "I"       
    id generator:'assigned'
    version: false   
}   
static constraints = {
}
}

Then this won’t work:

def c = L.withCriteria {
  lis {
    i {                   
      eq("a.id","A01")                                 
    }
  }
}

if you write just:

def c = L.withCriteria {
  lis {
    i {                   

    }
  }
}

this will give the same original error. Something is not correct.

  • 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-13T13:47:44+00:00Added an answer on June 13, 2026 at 1:47 pm

    I’ve got the same error here. It’s something on the criteria, but writing a little bit different works:

    def c = L.withCriteria {
      lis {
        eq('i.id',"I01") 
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following query which works fine for me except one problem SELECT
I have the following problem. I wrote a query to get the date of
I'm looking for help to create a query, to solve the following problem: Let's
Following problem: I want to render a news stream of short messages based on
I am looking to get a list of all of the groups that a
I need some help with my problem. I have created a list of all
I want to make a criteria query that has the same behaviour as the
My simplified and contrived example is the following:- Lets say that I want to
In the following code, the header: line is giving problem. $q = mysql_query($a) or
I am having problems with the following query in Castle ActiveRecord 2.12: var q

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.