True, i made this as an example, the code must be:
String sql = "SELECT
A.NAME "
+ " FROM A,"
+ "WHERE
A.ID = :param";
RawSql rawSql =
RawSqlBuilder.parse(sql).columnMapping("
A.NAME","name").create();
Query<Persons> query = Ebean.find(Persons.class);
query.setRawSql(rawSql);
query.setParameter("param", 0);
list = query.findList();
the exception is:
"Query threw SQLException:Invalid column index
Bind values:[0, ]
Query was:
select
A.NAME FROM A
WHERE
A.ID = ?
"
The issue is that, without the parameter (":param") and setParameter
in the query, the query runs ok and return mapped entities, but when i
try to set a parameter this way, throws an exception.
I saw an enhacement with number 304 (in the avagé page) presumably
solved this issue in the 2.7.0, (i using the 2.7.4).
In brief, Iam confused.
Please some help.
On 2 feb, 08:24, Rob Bygrave <
robin.bygr...@gmail.com> wrote:
> Hmm. You are only mapping one of the columns - that could be an issue.
>
> Your code doesn't look quite right. The type of the query [LicensesSales]
> is different to the class passed to the find [Persons] - so I don't that
> should compile?
>
> On 1 February 2012 12:42, claudio lezcano <
claudio...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Just a little aclaration, the type of the query is Person, the query
> > doesn't take parameters, but without them (the parameters), the query runs
> > ok and retrieve mapped rows.
>
> > 2012/1/31 Claudio Lezcano <
claudio...@gmail.com>
>
> >> Hi everybody i have some problems setting parameters into a query
> >> builded from a raw query, the specific case is:
>
> >> String sql = "SELECT
A.NAME, B.PERSON_ID "
> >> + " FROM A, B,"
> >> + "WHERE
B.ID =
A.ID "
> >> +" AND
B.ID > :param";
> >> RawSql rawSql =
> >> RawSqlBuilder.parse(sql).columnMapping("
A.NAME",
> >> "customerName").create();
>
> >> Query<LicensesSales> query = Ebean.find(Persons.class);
> >> query.setRawSql(rawSql);
> >> query.setParameter("param", 0);
> >> list = query.findList();
>
> >> I get the next exception:
>
> >> "Query threw SQLException:Invalid column index
> >> Bind values:[0, ]
> >> Query was:
> >> select
A.NAME, B.PERSON_ID
> >> FROM A, B,
> >> WHERE
B.ID =
A.ID
> >> AND
B.ID > ?
>
> >> "
>
> >> could someone help me please?
> >> Regards.
>
> > --
>
> > *Atte.*
> > *
>
> > Claudio Lezcano
>
> >
claudio...@gmail.com
>
> > Tel.: (595 985) 729 683
> > *