I have got an entity Product
@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
}
Here how I'm trying to query by example:
ProductEntity product = new ProductEntity();
product.setId(productId);
Example<ProductEntity> ex = Example.of(product);
Page<ProductEntity> pages = productRepository.findAll(ex, page);
But I get PostgreSQL error: PSQLException: ERROR: syntax error at or near "L".
Here's query that was created:
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 ?
The systax error is here:
where (productent0_.id=1L )
It adds 'L' character for Long value. So, how can I solve this problem?
UPDATE: Any idies? Still can't solve this problem.
UPDATE: My repository:
public interface CrudProductRepository extends JpaRepository<ProductEntity, Long>{
}
The package of JpaRepository:
import org.springframework.data.jpa.repository.JpaRepository;