Hibernate 3.2 -> 3.3

flutheronioneyedSoftware and s/w Development

Dec 13, 2013 (3 years and 9 months ago)

93 views

Hibernate 3.2 -> 3.3
New Second-level Caching SPIs
The old CacheProvider interfaces/impls are still around with bridges to the new APIs, so this is more of

a heads-up. Currently only the integration with JBossCache 2.x via the hibernate-jbosscache2 module

takes advantage of the new SPIs.

slf4j
Hibernate has migrated to using slf4j as the logging framework. A significant difference between the

two is that slf4j requires that users (at least) select which logging backend they want to use. This is

accomplished by defining a dependency on the appropriate logging bridge (slf4j-log4j for example) if

using maven or by dropping any needed jars on your classpath. See Steve's module blog entry for

details.
root change:
113,118d112
lines:1099-1104
triggered backend upgrade of log4j
373c293
lines: 1077-1083
javassist
Javassist is now the default bytecode provider rather than cglib.
root change:
106,109d105
lines: 3-7
triggered change in child POM:
241,245c241
lines: 987-994
-------------------------------------------------------------------------------
Hibernate 3.3 -> 3.5

Hibernate properties configured as type="text" now map to JDBC LONGVARCHAR;
in pre-3.5

versions, text properties were mapped to JDBC CLOB. A new Hibernate type, materialized_clob, was

added to map Java String properties to JDBC CLOB. If an application has properties configured as

type="text" that are intended to be mapped to JDBC CLOB, then they should be changed to

type="materialized_clob" in hbm mapping files, or, if using annotations, @Type(type = "text") should

be replaced by @Lob.
see:
19c20
lines: 807-810
21c21
lines: 827-830
23c23
lines: 840-843

Numeric aggregate Criteria projections now return the same value type as their HQL

counterparts.
As a result, the return type from the following projections in org.hibernate.criterion have

changed:
"count" and "count distinct" projections now return a Long value (due to changes in CountProjection,

Projections.rowCount(), Projections.count( propertyName ), and

Projections.countDistinct( propertyName )).
"sum" projections return a value type that depends on the property type due to changes in

Projections.sum( propertyName ):
for properties mapped as Long, Short, Integer, or primitive integer types, a Long value is returned;
for properties mapped as Float, Double, or primitive floating point types, a Double value is returned.
Failing to adapt application code to these changes will cause: java.lang.ClassCastException
see:
lines: 34-55
lines: 309-317
lines: 323-330
lines: 338-356
lines: 374-463
lines: 931-98
6
------------------------------------------------------------------------------
Hibernate 3.5 -> 3.6
AnnotationConfigration merged into Configuration : for most users this is nothing to be concerned with

(aside from the fact that AnnotationConfiguration is now deprecated). However, for users still using

hbm.xml you should be aware that we chose to use the org.hibernate.cfg.EJB3NamingStrategy used in

AnnotationConfigration instead of the older org.hibernate.cfg.DefaultNamingStrategy historically used

on Configuration. This may cause naming mismatches; one known place where this is an issue is if

you rely on the naming strategy to default the name of a association (many-to-many and collections of

elements) table. If you find yourself in this situation, you can tell Hibernate to use the the legacy

org.hibernate.cfg.DefaultNamingStrategy by calling Configuration#setNamingStrategy and passing it

org.hibernate.cfg.DefaultNamingStrategy#INSTANCE
The namespaces for the Hibernate dtd files have changed.
From

http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd to

http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd and from

http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd to http://www.hibernate.org/dtd/hibernate-
mapping-3.0.dtd
see: This is trivial, so I won't list all the lines. But it's essentially every .hbm.xml file.
If you are using Oracle, the global environment variable, hibernate.jdbc.use_streams_for_binary, must

be set to true if you are using materialized_clob or materialized_blob properties. In addition, using

java.sql.Clob and java.sql.Blob properties with Oracle is currently broken. See HHH-5659 for details.
If you are using PostgreSQL, the global environment variable, hibernate.jdbc.use_streams_for_binary,

must be set to false if you are using clob or blob properties. In addition, using materialized_blob and

materialized_clob properties with PostgreSQL is currently broken. See HHH-4617 for details
-------------------------------------------------------------------------------
Other changes:
Hibernate core pom upgrade:
111,127c107
lines: 8-32
All instances of Expression were depricated. New equivelent is Restrictions.
see: numerous changes in the diff.
Updated the Identity generator:
lines 357-372
Modified Hibernate core (not included in the diff):
lines 226-232 of hibernate-core-3.6.x-mod/hibernate-
core/src/main/java/org/hibernate/mapping/SimpleValue.java
orig:
public boolean isIdentityColumn(IdentifierGeneratorFactory identifierGeneratorFactory, Dialect

dialect) {
identifierGeneratorFactory.setDialect( dialect );
return identifierGeneratorFactory.getIdentifierGeneratorClass( identifierGeneratorStrategy )
.equals( IdentityGenerator.class );
}
new:
public boolean isIdentityColumn(IdentifierGeneratorFactory identifierGeneratorFactory, Dialect

dialect) {
identifierGeneratorFactory.setDialect( dialect );
return IdentityGenerator.class.isAssignableFrom(
identifierGeneratorFactory.getIdentifierGeneratorClass(identifierGeneratorStrategy));
}
All the source code for hibernate mod and the whole gsoc project is available on github.
Working copy of openmrs: https://github.com/czakian/openmrs_gsoc
Hibernate mod: https://github.com/czakian/hibernate-core-3.6.x-mod