我正在使用@Modifying 和@Query 注释直接执行我的sql 语句,但是我得到一个错误,告诉我我的表没有映射,所以我不知道我做错了什么,这是我的代码:
@Repository
public interface TypesContratDaoJPA extends CrudRepository<Type, Long> {
@Query("select type_id from declaration_type where declaration_id=:declaration")
List<Integer> getListTypes(@Param("declaration") int declaration);
@Modifying
@Query("insert into declaration_type values(:declaration,:type)")
void addTypeToContrat(@Param("declaration") int declaration, @Param("type") int type);
@Modifying
@Query("delete from declaration_type where declaration_id=:declaration and type_id=:type")
void deleteTypeFromContrat(@Param("declaration") int declaration, @Param("type") int type);
}
我收到此错误:
Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: declaration_type is not mapped [delete from declaration_type where declaration_id=:declaration and type_id=:type]
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:133)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:157)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:164)
at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:670)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:23)
...
...
...
...
任何帮助将非常感激。
BIG阳
相关分类