@Test
public void DeleteStreetWithWhere(){
Configuration config=new Configuration().configure();
SessionFactory sf=config.buildSessionFactory();
Session session=sf.openSession();
Transaction tr=session.beginTransaction();
String hql="from Street where id=1 ";
try {
session.delete(hql);
tr.commit();
System.out.println("street delete sucessful!");
} catch (Exception e) {
e.printStackTrace();
tr.rollback();
System.out.println("street delete failued!");
}finally{
session.close();
}
}
为什么String hql="from Street where id=1 "; 这样不行,但看了网上都是这么做的呀,运行报如下错误:
org.hibernate.MappingException: Unknown entity: java.lang.String