小编SIn*_*sun的帖子

在 JQPL 查询中执行更新/删除查询

我在 JPQL 中有这样的插入查询:

@Modifying
    @Query(value = "insert into Product_Category (product_id, category_id , description , numberOfProduct, image, price ) values (:product_id, :category_id, :description, :numberOfProduct, :image, :price)", nativeQuery = true)
    void insertProduct(@Param("product_id") int product_id, @Param("category_id") int category_id,
            @Param("description") String description, @Param("numberOfProduct") int numberOfProduct,
            @Param("image") String image, @Param("price") int price);
Run Code Online (Sandbox Code Playgroud)

我不明白为什么这不起作用。我有这个错误:

javax.persistence.TransactionRequiredException: Executing an update/delete query
Run Code Online (Sandbox Code Playgroud)

jpql spring-data spring-boot

6
推荐指数
1
解决办法
1万
查看次数

java中如何将base64转换为MultipartFile

我有个问题。我想转换BufferedImage为 MultipartFile。首先,在我的 UI 上发送base64到服务器,在我的服务器上,我转换为BufferedImage之后我想要将 BufferedImage 转换为 MultipartFile 并保存在本地存储上。这是我的方法:

@PostMapping("/saveCategory")
    @ResponseStatus(HttpStatus.OK)
    public void createCategory(@RequestBody String category ) {



        BufferedImage image = null;
        OutputStream stream;
        byte[] imageByte;
        try {
            BASE64Decoder decoder = new BASE64Decoder();
            imageByte = decoder.decodeBuffer(category);
            ByteArrayInputStream bis = new ByteArrayInputStream(imageByte);
            image = ImageIO.read(bis);
            bis.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    String fileName = fileStorageService.storeFile(image );
Run Code Online (Sandbox Code Playgroud)

我的存储方法:

public String storeFile(MultipartFile file) {
        // Normalize file name
        String fileName = StringUtils.cleanPath(file.getOriginalFilename());
        try {
            // Check …
Run Code Online (Sandbox Code Playgroud)

base64 spring-boot

3
推荐指数
1
解决办法
2万
查看次数

PostgreSQL 中的主键不是 AUTO INCREMENT

我有表类别,我有 3 列category_id, category_name,category_description。当我执行不带category_id参数的插入脚本时,出现此错误:

ERROR:  null value in column "category_id" violates not-null constraint
DETAIL:  Failing row contains (null, T_601, Yojimbo).
SQL state: 23502
Run Code Online (Sandbox Code Playgroud)

这是我的选择脚本:

INSERT INTO category ( category_name, category_description)
    VALUES ('T_601', 'Yojimbo');
Run Code Online (Sandbox Code Playgroud)

这是我的桌子的图像: 吨

sql postgresql auto-increment

0
推荐指数
2
解决办法
6503
查看次数

如何在 BigQuery 中将整数转换为时间戳

我有这个整数:1514761200000我想将谁转换成时间戳。有谁知道这是怎么做到的吗?

datetime google-bigquery

0
推荐指数
1
解决办法
2959
查看次数