[hibernate-dev] Adding features to Dialect class

Łukasz Antoniak lukasz.antoniak at gmail.com
Mon Apr 23 12:18:44 EDT 2012


Totaly agree that expecting null to be equal to empty string in Java model is wrong.

IMO he has spotted that when null string reference is replaced with an empty string, Envers creates new revision. From database 
perspective (Oracle) two records does not differ in any way. This could be actually handled easily in Envers code. I thought that 
it would be more elegant to add new dialect feature, but if this behavior is special to Oracle, there is no need.

// Revision 1
em.getTransaction().begin();
StrTestEntity emptyEntity = new StrTestEntity("");
em.persist(emptyEntity);
em.getTransaction().commit();
// Should not generate revision after NULL to "" modification on Oracle. But now it does.
em.getTransaction().begin();
emptyEntity = em.find(StrTestEntity.class, emptyId);
emptyEntity.setStr(null);
em.merge(emptyEntity);
em.getTransaction().commit();

Will use dev mailing list. Sorry for that.

Steve Ebersole wrote:
 > Their better option is to apply a Type for String that handles this.
 > http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#types-registry
 >
 > This is the type of thing we will be able to handle automatically in 5.0
 >
 > But as for the forum user's exact question, personally I think him
 > expecting null and empty string *in the java model* to be handled
 > equally is just plain wrong.
 >
 > P.S., these kinds of questions should be directed at the dev list so we
 > can get everyone's input.


More information about the hibernate-dev mailing list