-->
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: problems upgrading using a criteria with postgresql 7.4
PostPosted: Sun Jan 04, 2004 4:39 am 
Newbie

Joined: Sun Jan 04, 2004 4:26 am
Posts: 3
Using Hibernate 2.1.1 and PostgreSQL 7.4, I'm trying to use the Criteria API to do a SELECT ... FOR UPDATE on a given table. If I include a

Code:
criteria.setLockMode(LockMode.UPGRADE);


I get the following Exception

Code:
132531 [tcpConnection-8080-2] WARN util.JDBCExceptionReporter  - SQL Error: 0, SQLState: 0A000
132531 [tcpConnection-8080-2] ERROR util.JDBCExceptionReporter  - ERROR: DECLARE CURSOR ... FOR UPDATE is not supported

132531 [tcpConnection-8080-2] WARN util.JDBCExceptionReporter  - SQL Error: 0, SQLState: 0A000
132531 [tcpConnection-8080-2] ERROR util.JDBCExceptionReporter  - ERROR: DECLARE CURSOR ... FOR UPDATE is not supported


However, if I remove the criteria.setLockMode() statement, life is good. I used p6spy to check the SQL generated when the setLockMode(LockMode.UPGRADE) is used and it looks fine. I copied it into a SquirrelSQL window and the SQL executes fine. The problem appears to occur after the response comes back.

Any thoughts?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 04, 2004 8:28 pm 
Newbie

Joined: Sun Jan 04, 2004 4:26 am
Posts: 3
Here's a small sample of code which will reproduce the problem:

Code:
        Criteria criteria = session.createCriteria(Account.class);
        criteria.setLockMode(LockMode.UPGRADE);
        criteria.add(Expression.eq("name", "Matt"));
        List accountList = criteria.list();
        assertNotNull(accountList);


And here's the hibernate mapping:

Code:
<hibernate-mapping>

    <class name="test.Account" table="TEST_ACCOUNT" lazy="true">
        <id name="accountId" type="long" column="ACCOUNT_ID" unsaved-value="null">
            <generator class="native"/>
        </id>

        <property name="name" column="NAME" length="255" type="string"/>
    </class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 04, 2004 8:29 pm 
Newbie

Joined: Sun Jan 04, 2004 4:26 am
Posts: 3
Ah, and the Account class itself

Code:
package test;

public class Account {
    private Long accountId;
    private String name;

    public Long getAccountId() {
        return accountId;
    }

    public void setAccountId(Long accountId) {
        this.accountId = accountId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 05, 2004 12:12 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Sounds more like a driver / DB limitation, but I'm not very good on such a subject and I've never used postgresql 7.4. Can you pack your simple testcase and post it into JIRA ?

_________________
Emmanuel


Top
 Profile  
 
 Post subject: hibernate.jdbc.fetch_size causes this error for me
PostPosted: Fri Apr 22, 2005 10:24 am 
Newbie

Joined: Tue Jan 04, 2005 4:52 pm
Posts: 13
Hello,

Postgresql 7.4.x and 8.x do not support updateable cursors which is the cause of the exception.

Hibernate trys to declare an updateable cursor when you specify the hibernate.jdbc.fetch_size configuration parameter.

This bug showed up for me with Hql queries when setting the lock mode manuallly.

Simply commenting out the parameter made things work.

Kastor


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.