Bug 290 : Support where in () for EmbeddedId using expanded format
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
2.6.0
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
03/05/2010
Updated 
03/05/2010
Type 
Bug
 
Attachments 
No attachments

Hello,

We sometimes get errors with queries that look like this:

where (t.CompanyCode,t.DivisionCode,t.PSchedNo) in ((?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?))

Looks like the in clause for embedded id's with compound primary keys fails. We changed it to generate sql like this (in cases of compound pk's):

where ((t.CompanyCode = ? and t.DivisionCode = ? and t.PSchedNo = ?) or (t.CompanyCode = ? and t.DivisionCode = ? and t.PSchedNo = ?) or (t.CompanyCode = ? and t.DivisionCode = ? and t.PSchedNo = ?))

See the patch attached.

Cheers, Rien

 
Rob 03 May 01:47
((?,?,?),(?,?,?),(?,?,?),(?,?, ... supported in most DB's

> ((?,?,?),(?,?,?),(?,?,?),(?,?, ...

This form works in the other databases. Specifically Oracle, Postgres, MySql and h2.

Making it configurable at the DatabasePlatform.

Rob 03 May 01:51
Fixed in HEAD

Fixed in HEAD.

For DatabasePlatforms using the "expanded form" for where id in ... you need to set:

idInExpandedForm = true

For example refer to this ModifiedH2Platform:

package com.avaje.tests.compositekeys;

import com.avaje.ebean.config.dbplatform.H2Platform;

public class ModifiedH2Platform extends H2Platform {

    public ModifiedH2Platform() {
        super();
        this.idInExpandedForm = true;
    }
}

woResponse

Upload a file