hibernate中session.delete(sql),3.1與2.0的區(qū)別,導(dǎo)致的錯(cuò)誤
?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)
昨天的問(wèn)題解決了
| |
回復(fù)人:pdvv(我愛(ài)花貓) | 2006-3-1 17:32:22 | 得分:0 | ||
? |
| |||
Top | ||||
回復(fù)人:yuanjian0211(元?jiǎng)? | 2006-3-1 17:46:04 | 得分:0 | ||
? |
| |||
Top | ||||
回復(fù)人:yuanjian0211(元?jiǎng)? | 2006-3-1 17:56:29 | 得分:0 | ||
? |
| |||
Top | ||||
回復(fù)人:iori_powermax() | 2006-03-02 01:06:00 | 得分:0 | ||
? |
| |||
Top | ||||
回復(fù)人:ymfhcn(這痞子真帥) | 2006-03-02 08:06:00 | 得分:0 | ||
? |
?| = | 一般分類 | 仙俠修真 | VBScript | .NET | 面試題 | 存儲(chǔ)過(guò)程 | Hibernate | JavaScript | J2EE | Struts =========================================================== Hibernate 的 session.delete(obj =========================================================== 作者: iceling2008(http://iceling2008.itpub.net) 發(fā)表于:2006.03.30 16:33 分類: Hibernate 出處:http://iceling2008.itpub.net/post/13270/64328 --------------------------------------------------------------- session.delete(obj)將obj的狀態(tài)變?yōu)閠ransient。兩種情況 這兩種情況都是允許的,hibernate都會(huì)發(fā)送一條delete語(yǔ)句給數(shù)據(jù)庫(kù)。 delete執(zhí)行之后,如果調(diào)用了session.load(), 又可以分為兩種情況:1)在session.flush()之前,如: 2)在session.flush()之后,如: tx.beginTransaction(); delete執(zhí)行之后,如果調(diào)用了session.save(obj): - 作者: HairRoot 2005年05月 |
hibernate連接sqlserver2000問(wèn)題的解決
超強(qiáng)的貼,每句都是經(jīng)典
http://iceling2008.itpub.net/category/13270/23134好東西???????? 阿法薩
http://comsmall.spaces.live.com/PersonalSpace.aspx?_c02_owner=1
遇到 "Automation服務(wù)器不能創(chuàng)建對(duì)象"
運(yùn)行 Regsvr32 scrrun.dll。