-->
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: hibernate3 generates illegal for update of null, tablename
PostPosted: Fri Mar 11, 2005 1:53 am 
Newbie

Joined: Fri Mar 11, 2005 1:16 am
Posts: 3
The query.setXxx methods are pretty good about detecting attempts to set things which don't exist in your query, can setLockMode be made to also do this?

Details leading to the above request:

This worked in hibernate2. In hibernate3, its attempting to lock a null table. Ok, I see the problem in the below (marked with BAD LINE), however, i'll post this anyway (with the above request, and to assist anyone else searching for help with a similar message from their database) as hibernate generated a bad query, and left it up to the database to get upset about it.


Hibernate version: 3.0rc1

Code between sessionFactory.openSession() and session.close():

eiQ = hsession.createQuery("from EquipmentInstance as ei where ei.id =
:id");
eiQ.setLockMode("ei", LockMode.UPGRADE);
eQ = hsession.createQuery("from Entity as e where e.id =
:id");
eQ.setLockMode("e", LockMode.UPGRADE);
ei2aQ = hsession.createQuery("from
EquipmentInstance2Attribute as ei2a where ei2a.id = :id");
-->BAD LINE (should be ei2aQ): eQ.setLockMode("ei2a", LockMode.UPGRADE);
...
eQ.setString("id", eimw.getStrVal());
e = (Entity)eQ.uniqueResult();

Full stack trace of any exception that occurs:

(postgres log info:)
2005-03-10 18:29:58 ERROR: syntax error at or near "null" at character 364
2005-03-10 18:29:58 LOG: statement: rollback; begin;
2005-03-10 18:29:58 LOG: statement: end

Name and version of the database you are using:
PostgreSQL 8.0

The generated SQL (show_sql=true):

Hibernate: select entity0_.id as id, entity0_.active_dts as active2_0_,
entity0_.deactive_dts as deactive3_0_, entity0_.first_name as first4_0_,
entity0_.last_name as last5_0_, entity0_.company as company0_,
entity0_.comment as comment0_, entity0_.special_code as special8_0_,
entity0_.entity_type_id as entity9_0_ from entity entity0_ where
(entity0_.id=?) for update of null, entity0_

_________________
The second 'u' in 'nuclear' is silent, dagnabit!


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.