我正在使用 hibernate 和 oracle 开发 java web 应用程序。我已经设置了两个这样的实体
@Entity
public class Student{
@Id
Long id;
String name;
}
@Entity
public class Exam{
@Id
Long id;
String status;
@ManyToOne
Student student;
}
当我像这样在休眠中使用选择查询时
String hql="from Exam exam where exam.student.name=:name"
它工作正常但是当我像这样在休眠中使用更新查询时
String hql="update Exam exam set status=:status where exam.student.name=:name"
它产生以下错误
org.hibernate.exception.SQLGrammarException: ORA-00971: missing SET keyword
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:122)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at $Proxy154.executeUpdate(Unknown Source)
at org.hibernate.hql.internal.ast.exec.BasicExecutor.execute(BasicExecutor.java:103)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:413)
at org.hibernate.engine.query.spi.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:282)
at org.hibernate.internal.SessionImpl.executeUpdate(SessionImpl.java:1267)
at org.hibernate.internal.QueryImpl.executeUpdate(QueryImpl.java:116)
难道我做错了什么?