2 Replies Latest reply on May 10, 2010 7:12 AM by Paul Dunster

    Hibernate case sensitivity problem

    Paul Dunster Newbie

      Hi everyone, I'm after some help please.


      I have a case-sensitivity problem with Hibernate.  Essentially I have no option but to support a customer that requires a case INSENSITIVE SQL DB.  At the time we agreed to do this, the software ran using JBOSS 4.0.5. For many reasons we settled for a major hack to get hibernate working in an acceptable manor so that the following is permissible :-


      In business logic on a stateless session bean, we may need to load (using an EntityManager) a salesorderitem entity. 
      The salesorderitem entity has a ManyToOne join to the ProductEntity.  For this specific salesorderitem record, the productId may be in lowercase, but on the Product record, the productId may be upper case. We may then need to get one of the properties from the ProductEntity using the aforementioned join.  In other words, case INSENSITIVE joins.


      The hack was to use an AOP approach to replace the hibernate code that prevents the above scenario.  I'm told that the following
      classes and methods were identified as the reason we had to do this :-


      org.hibernate.loader.Loader#getKeyFromResultSet - changed so that the EntityKey returned has the persisted pk Id, not the one used to load the record.


      org.hibernate.util.EqualsHelper#equals - change to use equalsIgnoreCase if the two objects being compared were Strings.


      Due to time constraints, commercial pressures blar blar blar, we went with this, as it worked.


      Now the problem, since we went to JBOSS 4.2.3, with a newer version of the hibernate3 jar, this 'solution'
      has stopped working.


      Does anyone know of a better approach to solving our problem?  If not, does anyone know what was changed in hibernate that would inforce case SENSITIVE joins?


      Thanks in advance, Paul.