-->
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.  [ 5 posts ] 
Author Message
 Post subject: Bug? Problems using lock for update with MSSQL 2000
PostPosted: Wed Jul 13, 2005 3:41 pm 
Newbie

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

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 method Select.toStatementString is wrong: instead of
buf.append("select ").append(selectClause)
.append(" from ").append(fromClause);

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


Please, can you tell me, if this is a real bug or if we are using it the wrong way?
If it is a bug: is the solution as simple as supposed above?

Thank you in advance
Markus


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


Hibernate version:
3.0.2

Mapping documents:
<hibernate-mapping>
<class table="Campaign" name="net.atrada.muppets.domain.Campaign">
<id unsaved-value="0" name="id" column="campaignid">
<generator class="identity"/>
</id>
<timestamp unsaved-value="null" name="lastChange" column="campaignlastchange"/>
<many-to-one column="campaignauthor" class="net.atrada.muppets.domain.Member" lazy="true" name="author"/>
<property name="cashTime" column="campaigncashtime"/>
<property name="code" column="campaigncode"/>
<property name="end" column="campaignend"/>
<property name="event" column="campaignevent"/>
<property name="lastUpdate" column="campaignlastupdate"/>
<property name="lowerLimit" column="campaignlowerlimit" type="net.atrada.muppets.persistence.hibernate.usertype.MoneyUserType"/>
<property name="name" column="campaignname"/>
<property name="quantity" column="campaignquantity"/>
<property name="start" column="campaignstart"/>
<property name="type" column="campaignvouchertype" type="net.atrada.muppets.persistence.hibernate.usertype.VoucherTypeUserType"/>
<property name="value" column="campaignvalue" type="net.atrada.muppets.persistence.hibernate.usertype.MoneyUserType"/>
<one-to-one name="eventVoucher" lazy="true" class="net.atrada.muppets.domain.EventVoucher" property-ref="campaign" cascade="all"/>
<set inverse="true" cascade="all" lazy="true" name="vouchers">
<key column="vouchercampaignid"/>
<one-to-many class="net.atrada.muppets.domain.Voucher"/>
</set>
<property name="activateDate" column="campaignactivatedat"/>
<property name="createDate" column="campaigncreatedat"/>
<property name="pauseDate" column="campaignpausedat"/>
<property name="generatedVouchers" column="campaigngeneratedvouchers"/>
</class>
</hibernate-mapping>


Full stack trace of any exception that occurs:
no exception

Name and version of the database you are using:
MS SQL Server 8.0
org.hibernate.dialect.SQLServerDialect

The generated SQL (show_sql=true):
13.07.2005 21:30:27 DEBUG org.hibernate.SQL: select campaign0_.campaignid as campaignid0_, campaign0_.campaignlastchange as campaign2_74_0_, campaign0_.campaignauthor as campaign3_74_0_, campaign0_.campaigncashtime as campaign4_74_0_, campaign0_.campaigncode as campaign5_74_0_, campaign0_.campaignend as campaign6_74_0_, campaign0_.campaignevent as campaign7_74_0_, campaign0_.campaignlastupdate as campaign8_74_0_, campaign0_.campaignlowerlimit as campaign9_74_0_, campaign0_.campaignname as campaig10_74_0_, campaign0_.campaignquantity as campaig11_74_0_, campaign0_.campaignstart as campaig12_74_0_, campaign0_.campaignvouchertype as campaig13_74_0_, campaign0_.campaignvalue as campaig14_74_0_, campaign0_.campaignactivatedat as campaig15_74_0_, campaign0_.campaigncreatedat as campaig16_74_0_, campaign0_.campaignpausedat as campaig17_74_0_, campaign0_.campaigngeneratedvouchers as campaig18_74_0_ from Campaign campaign0_ where campaign0_.campaignid=?

Debug level Hibernate log excerpt:
13.07.2005 21:30:27 DEBUG org.hibernate.event.def.DefaultLoadEventListener: attempting to resolve: [net.atrada.muppets.domain.Campaign#1]
13.07.2005 21:30:27 DEBUG org.hibernate.event.def.DefaultLoadEventListener: object not resolved in any cache: [net.atrada.muppets.domain.Campaign#1]
13.07.2005 21:30:27 DEBUG org.hibernate.persister.entity.BasicEntityPersister: Materializing entity: [net.atrada.muppets.domain.Campaign#1]
13.07.2005 21:30:27 DEBUG org.hibernate.loader.Loader: loading entity: [net.atrada.muppets.domain.Campaign#1]
13.07.2005 21:30:27 DEBUG org.hibernate.jdbc.AbstractBatcher: about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
13.07.2005 21:30:27 DEBUG org.hibernate.SQL: select campaign0_.campaignid as campaignid0_, campaign0_.campaignlastchange as campaign2_74_0_, campaign0_.campaignauthor as campaign3_74_0_, campaign0_.campaigncashtime as campaign4_74_0_, campaign0_.campaigncode as campaign5_74_0_, campaign0_.campaignend as campaign6_74_0_, campaign0_.campaignevent as campaign7_74_0_, campaign0_.campaignlastupdate as campaign8_74_0_, campaign0_.campaignlowerlimit as campaign9_74_0_, campaign0_.campaignname as campaig10_74_0_, campaign0_.campaignquantity as campaig11_74_0_, campaign0_.campaignstart as campaig12_74_0_, campaign0_.campaignvouchertype as campaig13_74_0_, campaign0_.campaignvalue as campaig14_74_0_, campaign0_.campaignactivatedat as campaig15_74_0_, campaign0_.campaigncreatedat as campaig16_74_0_, campaign0_.campaignpausedat as campaig17_74_0_, campaign0_.campaigngeneratedvouchers as campaig18_74_0_ from Campaign campaign0_ where campaign0_.campaignid=?
13.07.2005 21:30:27 DEBUG org.hibernate.jdbc.AbstractBatcher: preparing statement
13.07.2005 21:30:27 DEBUG org.hibernate.type.LongType: binding '1' to parameter: 1
13.07.2005 21:30:30 DEBUG org.hibernate.jdbc.AbstractBatcher: about to open ResultSet (open ResultSets: 0, globally: 0)
13.07.2005 21:30:30 DEBUG org.hibernate.loader.Loader: processing result set
13.07.2005 21:30:30 DEBUG org.hibernate.loader.Loader: result set row: 0
13.07.2005 21:30:30 DEBUG org.hibernate.loader.Loader: result row: EntityKey[net.atrada.muppets.domain.Campaign#1]
13.07.2005 21:30:30 DEBUG org.hibernate.loader.Loader: Initializing object from ResultSet: [net.atrada.muppets.domain.Campaign#1]
13.07.2005 21:30:30 DEBUG org.hibernate.persister.entity.BasicEntityPersister: Hydrating entity: [net.atrada.muppets.domain.Campaign#1]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 13, 2005 6:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This SQL Server specific problem is a very well-known limitation in the current release.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 14, 2005 3:33 am 
Newbie

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

thank you for your answer. However, I did not found any hint on this topic in the bug database, on hibernate.org or in the developer mailing list.

Can you give me some information (or a link):

- Is there a work around or any documentation available?
- Will there be a fix availbale (planned date and version)?
- Is this problem already solved in the 3.1 version?

If not:
- Do you see any side effects if I solve the problem as mentioned in my previous post (adapt the 'Select.toStatementString' method)?
- From an architectural point of view: Is there a better approach to solve this problem?

Thank you in advance

Markus


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 22, 2005 10:33 pm 
Newbie

Joined: Fri Jun 03, 2005 9:03 pm
Posts: 5
I don't think that your fix would work. But I just went through the code quickly.
I fixed this problem by creating an SQL query for my MS SQL server, and it works fine.
You can definetly create a simple SQL query and submit it using the API provided in the session.
http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#querysql


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 04, 2006 2:28 pm 
Senior
Senior

Joined: Wed Sep 24, 2003 3:01 pm
Posts: 158
Location: Bragan�a Paulista - Brasil
Hi all,

I´m using Hibernate 3, Spring, Struts, SQL Server 2005.

About the use of (updlock) of SQL Server and the get method of
session.

In the last versions, is this supportted by Hibernate?

I´m looking for this in documentation, but :-(

_________________
Tads


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.