开发Hirbernate出错!
package hibproj;
import net.sf.hibernate.*;
import net.sf.hibernate.cfg.*;
class Test {
public static void main(String[] args) {
try{
SessionFactory sf=new Configuration().configure().buildSessionFactory();
Session session=sf.openSession();
Transaction tx=session.beginTransaction();
int i=session.delete("from CUSTOMER where CID=1");
System.out.print(i);
tx.commit();
session.close();
}
catch(HibernateException e)
{
e.printStackTrace();
}
}
}
0:34:35,453 INFO UpdateTimestampsCache:35 - starting update timestamps cache at region: net.sf.hibernate.cache.UpdateTimestampsCache
20:34:35,463 INFO StandardQueryCache:41 - starting query cache at region: net.sf.hibernate.cache.StandardQueryCache
Hibernate: select from where (CID=1 )
20:34:35,723 WARN JDBCExceptionReporter:38 - SQL Error: 936, SQLState: 42000
20:34:35,723 ERROR JDBCExceptionReporter:46 - ORA-00936: 缺少表达式
20:34:35,723 WARN JDBCExceptionReporter:38 - SQL Error: 936, SQLState: 42000
20:34:35,723 ERROR JDBCExceptionReporter:46 - ORA-00936: 缺少表达式
20:34:35,723 ERROR JDBCExceptionReporter:38 - Could not execute query
java.sql.SQLException: ORA-00936: 缺少表达式
问题点数:0、回复次数:3Top
1 楼niyboy(I Love J2EE)回复于 2004-09-01 08:54:13 得分 0
int i=session.delete("from CUSTOMER where CID=1");
这句应有问题吧;
from CUSTOMER.CUSTOMER where CUSTOME.CID=:1Top
2 楼steven760812()回复于 2004-09-01 08:56:10 得分 0
from CUSTOMER where CID=1应该改为 from CUSTOMER customer where customer.CID=1Top
3 楼fmzbj(mz)回复于 2004-09-01 09:02:57 得分 0
对的,在Hibernate里边你应该写上别名:from CUSTOMER customer where customer.CID=1
Top




