Enhancement 304 : ENHANCEMENT - Add support for named and positioned parameters in RawSql
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
2.7.0
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
26/05/2010
Updated 
26/05/2010
Type 
Enhancement
 
Attachments 
No attachments
RawSql rawSql = 
            RawSqlBuilder
                .parse("select r.id, r.name from o_customer r where r.id > :id and r.name like :name")
                .columnMapping("r.id", "id")
                .columnMapping("r.name", "name")
                .create();
                    
        Query<Customer> query = Ebean.find(Customer.class);
        query.setRawSql(rawSql);
        query.setParameter("name", "R%");
        query.setParameter("id", 0);
        query.where().lt("id", 1000);
        
        List<Customer> list = query.findList();

and...

RawSql rawSql = 
            RawSqlBuilder
                .unparsed("select r.id, r.name from o_customer r where r.id >= ? and r.name like ?")
                .columnMapping("r.id", "id")
                .columnMapping("r.name", "name")
                .create();
                    
        Query<Customer> query = Ebean.find(Customer.class);
        query.setRawSql(rawSql);
        query.setParameter(1, 1);
        query.setParameter(2, "R%");
        
        List<Customer> list = query.findList();
 
Rob 26 May 10:57
Fixed in HEAD

fixed in HEAD.

woResponse

Upload a file