使用@entity注解替换表名,Dao层不能够使用实体名称作为注解

来源:互联网 发布:福昕阅读器mac版 下载 编辑:程序博客网 时间:2024/04/30 12:16

Error creating bean with name 'produceDao': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Produce is not mapped [update Produce a set a.clickNum = a.clickNum+1 where a.id = ?1 ]


@Entity

@Table(name = "t_produce")
public class Produce implements Serializable  {

private static final long serialVersionUID = 1L;

public Produce(){
super();

}

}

Dao层必须使用:

@Modifying
@Query("update Produce a set a.clickNum = a.clickNum+1 where a.id = ?1 ")
public void updateClickNum(int id);



@Entity(name = "t_produce")
public class Produce implements Serializable  {

private static final long serialVersionUID = 1L;

public Produce(){
super();

}

}

Dao层必须使用:

@Modifying
@Query("update t_produce a set a.clickNum = a.clickNum+1 where a.id = ?1 ")
public void updateClickNum(int id);