I'm trying to run a ejbql in my application but it's failing with the following error: java.lang.IllegalStateException: invalid select clause for query.
This is the query:
public void pesquisar()
{
StringBuilder query = new StringBuilder();
query.append("SELECT OBJECT(licenca) FROM TblLicencas licenca");
query.append(" WHERE upper(licenca.tblLivros.titulo) like '%" + termoPesquisa.toUpperCase() + "%'");
tblLicencasList.setEjbql(query.toString());
tblLicencasList.refresh();
}
In console, the output query generated by hibernate is this:
select
top 26 tbllicenca0_.id_licenca as id1_8_,
tbllicenca0_.data_geracao as data2_8_,
tbllicenca0_.id_livraria as id3_8_,
tbllicenca0_.id_livro as id4_8_,
tbllicenca0_.id_status_licenca as id5_8_,
tbllicenca0_.id_tipo_licenca as id6_8_
from
DigitalDocumentsServerTeste.dbo.tbl_licencas tbllicenca0_,
DigitalDocumentsServerTeste.dbo.tbl_livros tbllivros1_
where
tbllicenca0_.id_livro=tbllivros1_.id_livro
and (
upper(tbllivros1_.titulo) like '%ADV%'
)
In my application i have several other queries similar to this that work perfectly. When i mannualy execute this query in the database, it works well. I'm using SQL Server 2005.
Thanks