Datos JPA. Consulta por ejemplo. No se puede buscar con el valor largo
Tengo una entidad Producto
@Entity
@Table(name = "Products")
public class ProductEntity implements Serializable{
@Id
@GenericGenerator(name = "generator", strategy = "increment")
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@Column(name = "model", nullable = false)
,private String model;
//setters and getters
}
Aquí estoy tratando de consultar por ejemplo:
ProductEntity product = new ProductEntity();
product.setId(productId);
Example<ProductEntity> ex = Example.of(product);
Page<ProductEntity> pages = productRepository.findAll(ex, page);
Pero obtengo un error de PostgreSQL: PSQLException: ERROR: error de sintaxis en o cerca de "L".
Aquí está la consulta que se creó:
Hibernate: select productent0_.id as id1_13_, productent0_.brand_id as brand_id9_13_, productent0_.imgPath as imgPath2_13_, productent0_.model as model3_13_, productent0_.numberOfEvaluation as numberOf4_13_, productent0_.priceBuy as priceBuy5_13_, productent0_.priceSell as priceSel6_13_, productent0_.rating as rating7_13_, productent0_.sumOfEvaluation as sumOfEva8_13_, productent0_.type_id as type_id10_13_ from Products productent0_ where (productent0_.id=1L ) limit ?
El error de sintaxis está aquí:
where (productent0_.id=1L )
Agrega el carácter 'L' para el valor largo. Entonces, ¿cómo puedo resolver este problema?
ACTUALIZACIÓN: ¿Alguna idies? Aún no puedo resolver este problema.
ACTUALIZACIÓN: Mi repositorio:
public interface CrudProductRepository extends JpaRepository<ProductEntity, Long>{
}
El paquete de JpaRepository:
import org.springframework.data.jpa.repository.JpaRepository;