-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: bulk delete query not working
PostPosted: Fri Jul 21, 2006 2:06 pm 
Newbie

Joined: Tue Jun 20, 2006 10:30 pm
Posts: 6
I am using hibernate 3.0.5 with MSSQL Server 2005.

I have a table with the following xml :

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="com.hp.ov.amx.persistence.ConfigProfile" table="AMX_CONFIG_PROFILE">

<!-- Primary keys -->
<!-- NOTE - We do not need a primary key on this table,
this one is for hibernate
-->
<id name="id" type="long" column="CONFIG_PROFILE_ID">
<generator class="native" />
</id>


<!-- Foreign keys - other tables are dependent on columns this table -->
<many-to-one name="serviceGroup"
class="com.hp.ov.amx.persistence.ServiceGroup">
<column name="SERVICE_GROUP_UUID" not-null="true" length="32" sql-type="char(32)"/>
</many-to-one>

<many-to-one name="service"
class="com.hp.ov.amx.persistence.Service">
<column name="SERVICE_UUID" not-null="false" length="32" sql-type="char(32)"/>
</many-to-one>

<many-to-one name="profile" class="com.hp.ov.amx.persistence.Profile">
<column name="PROFILE_ID" not-null="true"/>
</many-to-one>

</class>
</hibernate-mapping>

I am trying to run the following bulk delete query :

Query configProfileDeleteQuery = session.createQuery(
"delete ConfigProfile cP where cP.profile.id = :prId "); configProfileDeleteQuery.setParameter("prId", new Long(10)); configProfileDeleteQuery.executeUpdate();

I get the following QuerySyntax Error :

org.hibernate.hql.ast.QuerySyntaxError: unexpected token: cP near line 1, column 22 [delete ConfigProfile cP where cP.profile.id = :prId ]
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:63)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:215)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:127)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
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)



Please help.

regards
-Sarab


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 21, 2006 2:18 pm 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
try with this:
Code:
delete ConfigProfile cP
where exists(
   from Profile p
   where
      p = cP.profile
      and
      p.id = :prId
)


Top
 Profile  
 
 Post subject: query parser still complaining about the query.
PostPosted: Fri Jul 21, 2006 2:43 pm 
Newbie

Joined: Tue Jun 20, 2006 10:30 pm
Posts: 6
Same problem. The query parser complains about the token "cP".


g.hibernate.hql.ast.QuerySyntaxError: unexpected token: cP near line 1, column 53 [delete from com.hp.ov.amx.persistence.ConfigProfile cP where exists ( from com.hp.ov.amx.persistence.Profile p where p = cP.profile and p.id = :prId ) ]
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:63)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:215)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:127)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)


-Sarab


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 21, 2006 4:19 pm 
Beginner
Beginner

Joined: Tue Sep 06, 2005 5:16 pm
Posts: 24
Location: USA
Code:
"delete ConfigProfile cP where cP.profile.id = :prId "


use this , just remove cP

Code:
"delete ConfigProfile where profile.id = :prId "


I'm 100% sure it'll work.


Top
 Profile  
 
 Post subject: Query parsed OK but failed to execute.
PostPosted: Fri Jul 21, 2006 4:35 pm 
Newbie

Joined: Tue Jun 20, 2006 10:30 pm
Posts: 6
A different error this time :

caused by: com.inet.tds.ao: Msg 4104, Level 16, State 1, Line 1, Sqlstate 01000
[ROS80965TST-VM1]The multi-part identifier "configprof0_.CONFIG_PROFILE_ID" could not be bound.
at com.inet.tds.al.a(Unknown Source)
at com.inet.tds.h.a(Unknown Source)
at com.inet.tds.h.a(Unknown Source)
at com.inet.tds.q.f(Unknown Source)
at com.inet.tds.q.executeUpdate(Unknown Source)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.hql.ast.UpdateStatementExecutor.execute(UpdateStatementExecutor.java:76)

-Sarab


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 5:22 pm 
Newbie

Joined: Wed Jul 26, 2006 9:53 pm
Posts: 16
I believe the DML style bulk updates are not available for Hibernate3.0.5.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.