Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlExceptionHelper : No value specified for parameter 2 #86

Open
ximBalaguer opened this issue Sep 21, 2018 · 5 comments
Open

SqlExceptionHelper : No value specified for parameter 2 #86

ximBalaguer opened this issue Sep 21, 2018 · 5 comments

Comments

@ximBalaguer
Copy link

Congratulations for your work. It's great.

I have a problem if I create a formula (@formula) with parameters.
In datatables, if I filter by the field linked to that formula, I get the following error:

Hibernate:
select
tercero0_.id as id1_3_,
tercero0_.apellidos as apellido2_3_,
tercero0_.fechaNacimiento as fechaNac3_3_,
tercero0_.nombre as nombre4_3_,
tercero0_.observaciones as observac5_3_,
tercero0_.persona as persona6_3_,
tercero0_.profesion as profesio7_3_,
tercero0_.salario as salario8_3_,
tercero0_.situacionId as situacio9_3_,
(SELECT
GROUP_CONCAT(TD.denominacion)
FROM
tr_tercerosDirecc TD
WHERE
TD.terceroId = tercero0_.id) as formula232_,
year(curdate())-year(tercero0_.fechaNacimiento) as formula233_
from
tr_terceros tercero0_
left outer join
tb_nodos nodo1_
on tercero0_.situacionId=nodo1_.id
order by
(SELECT
TD.denominacion
FROM
tb_nodosTraducs TD
WHERE
TD.nodoId = nodo1_.id
and TD.idiomaId = ?) asc limit ?
2018-09-21 08:38:35.309 WARN 7541 --- [nio-8081-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 07001
2018-09-21 08:38:35.309 ERROR 7541 --- [nio-8081-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper : No value specified for parameter 2
retornar=DataTablesOutput(draw=2, recordsTotal=20, recordsFiltered=0, data=[], error=javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet)


CONTROLLER
@JSONVIEW(DataTablesOutput.View.class)
@RequestMapping(value = "/findPaginados", method = RequestMethod.POST )
public @responsebody DataTablesOutput getTercerosPaginados(@Valid DataTablesInput input) {
Session session = (Session) entityManager.unwrap(Session.class);
session.enableFilter("filtroPorIdioma").setParameter("parIdioma", 12);
DataTablesOutput retornar = agenda.findAll(input);
return retornar;
}


MODEL*

@JsonView(DataTablesOutput.View.class)
@Formula("(SELECT TD.denominacion FROM tb_nodosTraducs TD WHERE TD.nodoId = id and TD.idiomaId = :filtroPorIdioma.parIdioma)")
private String denominacionTraducida;
@darrachequesne
Copy link
Owner

Hi! The @Formula annotation is not currently supported indeed.

I won't have time to take a look at it in the next few days, but I'll happily merge your fix if you find something 👍

@ximBalaguer
Copy link
Author

Thank you very much for your answer, Damien
The @formula works perfectly if it does not contain any parameters
If in my formula I include a parameter then the problem appears

@ximBalaguer
Copy link
Author

Hello Damien

Do you plan to implement this functionality in the future?
I, feeling it a lot, do not have enough knowledge to do it.
Thank you for your collaboration, Damien

1 similar comment
@ximBalaguer
Copy link
Author

Hello Damien

Do you plan to implement this functionality in the future?
I, feeling it a lot, do not have enough knowledge to do it.
Thank you for your collaboration, Damien

@darrachequesne
Copy link
Owner

@ximBalaguer no, I don't plan to implement it myself for now, as it is quite an uncommon use case. But as I said, if someone wants to implement it, I'll merge it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants