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: EntityPersister - Why no use of Types in update?
PostPosted: Wed Apr 06, 2005 7:01 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
Hibernate version: 2.1.8
Hi there,

i've got a question concerning the following method (@see EntityPersister):
Code:
   protected String generateUpdateString(boolean[] includeProperty, Object[] oldFields) {
      Update update = generateUpdate(includeProperty);
      if ( optimisticLockMode()>Versioning.OPTIMISTIC_LOCK_VERSION && oldFields!=null ) {
         boolean[] includeInWhere = optimisticLockMode()==Versioning.OPTIMISTIC_LOCK_ALL ?
            getPropertyUpdateability() :
            includeProperty;
         for ( int i=0; i<getHydrateSpan(); i++ ) {
            if ( includeInWhere[i] ) {
               if ( oldFields[i]==null) {
                  update.addWhereColumns( propertyColumnNames[i], " is null");
               }
               else {
                  update.addWhereColumns( propertyColumnNames[i] );
               }
            }
         }
      }
         
      return update.toStatementString();
   }


For oldFields with value "null", a "is null" is written to the generated sql-String. In my case, where 'null'-values aren't allowed in db (legacy!) the update-Statement won't work!
My UserTypes will switch all default values (which are set instead of 'null') to 'null', which means that the oldFieldValues are 'null' in the POJO, but not in db.
Therefore, in my case, it's wrong to write "is null" ...

Sure i can subclass the EntityPersiter, i've done that, but this leads into copiing the complete code into a new class, just to change a few lines of code, because the EntityPersister isn't subclassable ...

My question (or my suggestion) is, why not 'ask' the Type if the value is really 'null'?

Or isn't that a problem with hb3? I haven't got the possibility to migrate at the moment, but it would be good to know :)

thx!
curio


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.