hibernate中session.delete(sql),3.1與2.0的區別,導致的錯誤
?at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:569)
?at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1086)
?at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:63)
?at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:579)
??? find()、iterate()、filter()和delete(String?hqlSelectQuery),saveOrUpdateCopy()
????? org.hibernate.classic.Session?session=sessionFactory.openSession();?
Session?session?=?sessionFactory.openSession();?
Transaction?tx?=?session.beginTransaction();?
String?hqlDelete?=?"delete?Customer?where?name?=?:oldName";?
int?deletedEntities?=?s.createQuery(?hqlDelete?)?
.setString(?"oldName",?oldName?)?
.executeUpdate();?
tx.commit();?
session.close();
Session?session?=?sessionFactory.openSession();?
Transaction?tx?=?session.beginTransaction();?
String?hqlUpdate?=?"update?Customer?set?name?=?:newName?where?name?=?:oldName";?
int?updatedEntities?=?s.createQuery(?hqlUpdate?)?
.setString(?"newName",?newName?)?
.setString(?"oldName",?oldName?)?
.executeUpdate();?
tx.commit();?
session.close();?
org.hibernate.QueryException: query must begin with SELECT or FROM: delete [delete Resource r where r.nodeId=:nodeId and r.devId is not null ]
?at org.hibernate.hql.classic.ClauseParser.token(ClauseParser.java:83)
?at org.hibernate.hql.classic.PreprocessingParser.token(PreprocessingParser.java:108)
?at org.hibernate.hql.classic.ParserHelper.parse(ParserHelper.java:28)
?at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:176)
?at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:152)
?at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
?at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
?at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:865)
?at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:89)
昨天的問題解決了
| |
回復人:pdvv(我愛花貓) | 2006-3-1 17:32:22 | 得分:0 | ||
? |
| |||
Top | ||||
回復人:yuanjian0211(元劍) | 2006-3-1 17:46:04 | 得分:0 | ||
? |
| |||
Top | ||||
回復人:yuanjian0211(元劍) | 2006-3-1 17:56:29 | 得分:0 | ||
? |
| |||
Top | ||||
回復人:iori_powermax() | 2006-03-02 01:06:00 | 得分:0 | ||
? |
| |||
Top | ||||
回復人:ymfhcn(這痞子真帥) | 2006-03-02 08:06:00 | 得分:0 | ||
? |
?| = | 一般分類 | 仙俠修真 | VBScript | .NET | 面試題 | 存儲過程 | Hibernate | JavaScript | J2EE | Struts =========================================================== Hibernate 的 session.delete(obj =========================================================== 作者: iceling2008(http://iceling2008.itpub.net) 發表于:2006.03.30 16:33 分類: Hibernate 出處:http://iceling2008.itpub.net/post/13270/64328 --------------------------------------------------------------- session.delete(obj)將obj的狀態變為transient。兩種情況 這兩種情況都是允許的,hibernate都會發送一條delete語句給數據庫。 delete執行之后,如果調用了session.load(), 又可以分為兩種情況:1)在session.flush()之前,如: 2)在session.flush()之后,如: tx.beginTransaction(); delete執行之后,如果調用了session.save(obj): - 作者: HairRoot 2005年05月 |
hibernate連接sqlserver2000問題的解決
超強的貼,每句都是經典
http://iceling2008.itpub.net/category/13270/23134好東西???????? 阿法薩
http://comsmall.spaces.live.com/PersonalSpace.aspx?_c02_owner=1
遇到 "Automation服務器不能創建對象"
運行 Regsvr32 scrrun.dll。