-->
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.  [ 1 post ] 
Author Message
 Post subject: Problems using lock for update with MSSQL 2000
PostPosted: Wed Jun 29, 2005 9:44 am 
Newbie

Joined: Wed Jun 29, 2005 9:20 am
Posts: 3
Hi,

we are using Hibernate 3.0.2 and MS SQL Server 8.0 (org.hibernate.dialect.SQLServerDialect). When loading an Object with lock mode UPGRADE, the database does not lock the row.

When searching for the problem, we detected that the generated SQL Query contains the wrong from clause:

instead of "from campaign" it should be "from campaign with (updlock, rowlock)".


We assume that the Select.toStatementString is wrong: instead of
buf.append("select ").append(selectClause)
.append(" from ").append(fromClause);


it should integrate the lock clause as for example be done in SimpleSelect.toStatementString:
buf.append(" from ")
.append( dialect.appendLockHint(lockMode, tableName) );


Thank you in advance
Markus

Our code:
Campaign c = (Campaign) hSession.getSession().load(Campaign.class, new Long(1), LockMode.UPGRADE);

-> Hibernate Debug-Infos:

29.06.2005 15:31:59 DEBUG org.hibernate.event.def.DefaultLoadEventListener: attempting to resolve: [net.atrada.muppets.domain.Campaign#1]
29.06.2005 15:31:59 DEBUG org.hibernate.event.def.DefaultLoadEventListener: object not resolved in any cache: [net.atrada.muppets.domain.Campaign#1]
29.06.2005 15:31:59 DEBUG org.hibernate.persister.entity.BasicEntityPersister: Materializing entity: [net.atrada.muppets.domain.Campaign#1]
29.06.2005 15:31:59 DEBUG org.hibernate.loader.Loader: loading entity: [net.atrada.muppets.domain.Campaign#1]
29.06.2005 15:31:59 DEBUG org.hibernate.jdbc.AbstractBatcher: about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
29.06.2005 15:31:59 DEBUG org.hibernate.SQL: select campaign0_.campaignid as campaignid0_, campaign0_.campaignauthor as campaign2_66_0_, campaign0_.campaigncashtime as campaign3_66_0_, campaign0_.campaigncode as campaign4_66_0_, campaign0_.campaignend as campaign5_66_0_, campaign0_.campaignevent as campaign6_66_0_, campaign0_.campaignlastupdate as campaign7_66_0_, campaign0_.campaignlowerlimit as campaign8_66_0_, campaign0_.campaignname as campaign9_66_0_, campaign0_.campaignquantity as campaig10_66_0_, campaign0_.campaignstart as campaig11_66_0_, campaign0_.campaignvouchertype as campaig12_66_0_, campaign0_.campaignvalue as campaig13_66_0_ from Campaign campaign0_ where campaign0_.campaignid=?
29.06.2005 15:31:59 DEBUG org.hibernate.jdbc.AbstractBatcher: preparing statement
29.06.2005 15:31:59 DEBUG org.hibernate.type.LongType: binding '1' to parameter: 1
29.06.2005 15:31:59 DEBUG org.hibernate.jdbc.AbstractBatcher: about to open ResultSet (open ResultSets: 0, globally: 0)
29.06.2005 15:31:59 DEBUG org.hibernate.loader.Loader: processing result set
29.06.2005 15:31:59 DEBUG org.hibernate.loader.Loader: result set row: 0
29.06.2005 15:31:59 DEBUG org.hibernate.loader.Loader: result row: EntityKey[net.atrada.muppets.domain.Campaign#1]
29.06.2005 15:31:59 DEBUG org.hibernate.loader.Loader: Initializing object from ResultSet: [net.atrada.muppets.domain.Campaign#1]


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

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.