Я пытаюсь вставить , delte, метод обновления. Мой код:
package com.example.tx.repository;
import com.example.tx.entity.Blog;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
public interface BlogRepository extends CrudRepository<Blog,Long> {
@Transactional
@Modifying
@Query(value = "insert into blog (title,content) value(:title,:content)",nativeQuery = true)
void saveBlog(@Param("title") String title,@Param("content") String content);
@Transactional
@Modifying
@Query(value = "update blog set content = :content where id = :id" ,nativeQuery = true)
void update(@Param("id") Long id,@Param("content") String content);
@Transactional
@Modifying
@Query(value = "delete from blog where id = :id",nativeQuery = true)
void deleteWithId(@Param("id") Long id );
}
журнал идей
2020-04-29 14:50:26,110 restartedMain DEBUG AsyncLogger.ThreadNameStrategy=UNCACHED (user specified null, default is UNCACHED)
2020-04-29 14:50:26,110 restartedMain DEBUG org.apache.logging.log4j.core.util.SystemClock does not support precise timestamps.
14:50:26.112 [restartedMain] DEBUG com.example.tx.TxApplication - Running with Spring Boot v2.2.6.RELEASE, Spring v5.2.5.RELEASE
14:50:26.112 [restartedMain] INFO com.example.tx.TxApplication - No active profile set, falling back to default profiles: default
14:50:30.050 [restartedMain] INFO com.example.tx.TxApplication - Started TxApplication in 4.269 seconds (JVM running for 6.579)
Hibernate: update blog set content = ? where id = ?
не работает только метод обновления, данные не могут быть изменены, как их решить?