1

我有一个实体产品

@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
}

这里我试图通过示例进行查询:

ProductEntity product = new ProductEntity();
product.setId(productId);
Example<ProductEntity> ex = Example.of(product);
Page<ProductEntity> pages = productRepository.findAll(ex, page);

但是我收到 PostgreSQL 错误:PSQLException: ERROR: syntax error at or near "L"。

这是创建的查询:

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 ?

系统税错误在这里:

where (productent0_.id=1L )

它为 Long 值添加了“L”字符。那么,我该如何解决这个问题呢?

更新:有没有 idies?还是不能解决这个问题。

更新:我的存储库:

public interface CrudProductRepository extends JpaRepository<ProductEntity, Long>{
}

JpaRepository 的包:

import org.springframework.data.jpa.repository.JpaRepository;
4

0 回答 0