Categories
hibernate jpa repository spring sql

Error generated Hibernate Jpa Repository Query

I use this query with Jpa Repository:

@Query("select f.attrezzature from FoglioLavoro f where f.id = :idFoglioLavoro")
Page<AbstractAttrezzatura> findAttrezzaturaFoglioLavoro(@Param("idFoglioLavoro")Long idFoglioLavoro, Pageable pageable);

But when I use this query I obtain this error:

ERROR: org.hibernate.engine.jdbc.spi.SqlExceptionHelper - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') as col_0_0_ from foglio_lavoro fogliolavo0_, foglio_lavoro_attrezzature attrez' at line 1

And this is the generated spring-data query:

Hibernate: 
select
count(.) as col_0_0_
from
foglio_lavoro fogliolavo0_,
foglio_lavoro_attrezzature attrezzatu1_,
abstract_attrezzatura abstractat2_
where
fogliolavo0_.id=attrezzatu1_.fogli_lavoro
and attrezzatu1_.attrezzature=abstractat2_.id
and fogliolavo0_.id=?

How can I solve it??
Thank you very much