-->
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.  [ 3 posts ] 
Author Message
 Post subject: Potential issue with PostgresQLDialect and bulk update
PostPosted: Mon Oct 20, 2008 4:23 pm 
Newbie

Joined: Mon Oct 20, 2008 4:13 pm
Posts: 3
Location: Florida
Hibernate version: 3.2.5

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

Name and version of the database you are using: PostgresQL 8.2


I have a bulk update that looks something like "update A set X=:x where B in (:b_list)" (B is a class related by FK). When I execute this, I get an error that essentially says "org.postgresql.util.PSQLException: ERROR: relation "ht_B" does not exist"

After reading through the source code, I think I have found the issue with how the PostgreSQLDialect creates the temporary tables that are used to perform the bulk update. It appears temporary tables are only created once (at Session Factory initialization). In the Postgres dialect, the getCreateTemporaryTablePostfix method returns "on commit drop" -- which I think means "as soon as a commit has occurred on the session, drop this table." So once a commit has happened on the session (including commits having nothing to do with that temporary table), the ht_B table is gone. I think the getCreateTemporaryTablePostfix method should be returning "ON COMMIT DELETE ROWS" so that the temporary tables stay around through the duration.

I looked at a few other dialects -- Oracle uses "ON COMMIT DELETE ROWS". There's even one (TeradataDialect) that says "ON COMMIT PRESERVE ROWS" -- just out of curiosity, what would be the use of that?

Thanks in advance,
Mike Johnson


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2008 1:28 pm 
Newbie

Joined: Mon Oct 20, 2008 4:13 pm
Posts: 3
Location: Florida
As a followup, I created a new dialect:

Code:
import org.hibernate.dialect.PostgreSQLDialect;

public class BugfixPostgreSQLDialect extends PostgreSQLDialect {

   public String getCreateTemporaryTablePostfix() {
      return "on commit delete rows";
   }

}


And then ran my logic again with this dialect, and everything seems to work correctly. I am just hoping someone can give me some history as to why the original dialect has "on commit drop" -- there might be something I am missing here!!

If this does indeed need to get fixed, should I file a JIRA issue?

Thanks in advance,
Mike Johnson


Top
 Profile  
 
 Post subject: Just checking back
PostPosted: Mon Nov 10, 2008 9:23 am 
Newbie

Joined: Mon Oct 20, 2008 4:13 pm
Posts: 3
Location: Florida
I wanted to check again and see if any Hibernate gurus thought this would be a good candidate for a JIRA entry... I'll be happy to enter it if so!

Thanks,
Mike Johnson


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