Permalink
Browse files

upgrade to Hibernate 3.6

  • Loading branch information...
graemerocher committed Mar 24, 2011
1 parent a98339a commit 2a525be55068fda9cdc019e3635182fa22d4be99
View
@@ -69,6 +69,7 @@ subprojects { project ->
mavenCentral()
mavenRepo urls:"http://maven.springframework.org/release"
mavenRepo urls:'http://maven.springframework.org/snapshot'
+ mavenRepo name:'jboss-public', urls:'http://repository.jboss.org/nexus/content/groups/public-jboss/'
}
dependencies {
// Groovy
@@ -114,7 +115,7 @@ subprojects { project ->
// Specs
compile 'javax.servlet:servlet-api:2.5'
compile 'javax.transaction:jta:1.1'
- compile 'javax.persistence:persistence-api:1.0'
+ compile 'org.hibernate.java-persistence:jpa-api:2.0-cr-1'
// Spring
@@ -12,15 +12,13 @@ dependencies {
}
// Hibernate related
- compile 'org.hibernate:hibernate-annotations:3.4.0.GA',
- 'org.hibernate:hibernate-commons-annotations:3.1.0.GA',
- 'org.hibernate:hibernate-core:3.3.1.GA'
+ compile 'org.hibernate:hibernate-core:3.6.1.Final'
compile 'javassist:javassist:3.11.0.GA'
- runtime 'org.hibernate:hibernate-validator:3.1.0.GA',
- 'org.hibernate:hibernate-ehcache:3.3.1.GA',
+ runtime 'org.hibernate:hibernate-validator:4.1.0.Final',
+ 'org.hibernate:hibernate-ehcache:3.6.1.Final',
'antlr:antlr:2.7.6'
@@ -1119,13 +1119,13 @@ else if (paginationEnabledList) {
criteria.setFirstResult(0);
criteria.setMaxResults(Integer.MAX_VALUE);
criteria.setProjection(Projections.rowCount());
- int totalCount = ((Integer)criteria.uniqueResult()).intValue();
+ int totalCount = ((Number)criteria.uniqueResult()).intValue();
// Drop the projection, add settings for the pagination parameters,
// and then execute the query.
criteria.setProjection(null);
- for (Iterator<Order> it = orderEntries.iterator(); it.hasNext();) {
- criteria.addOrder(it.next());
+ for (Order orderEntry : orderEntries) {
+ criteria.addOrder(orderEntry);
}
if (resultTransformer == null) {
criteria.setResultTransformer(CriteriaSpecification.ROOT_ENTITY);
@@ -1200,17 +1200,17 @@ else if (paginationEnabledList) {
return name;
}
- if (targetBean.isReadableProperty(name.toString())) {
+ if (targetBean.isReadableProperty(name)) {
ClassMetadata meta = sessionFactory.getClassMetadata(targetBean.getWrappedClass());
- Type type = meta.getPropertyType(name.toString());
+ Type type = meta.getPropertyType(name);
if (type.isAssociationType()) {
String otherSideEntityName =
((AssociationType) type).getAssociatedEntityName((SessionFactoryImplementor) sessionFactory);
Class oldTargetClass = targetClass;
targetClass = sessionFactory.getClassMetadata(otherSideEntityName).getMappedClass(EntityMode.POJO);
BeanWrapper oldTargetBean = targetBean;
targetBean = new BeanWrapperImpl(BeanUtils.instantiateClass(targetClass));
- associationStack.add(name.toString());
+ associationStack.add(name);
final String associationPath = getAssociationPath();
createAliasIfNeccessary(name, associationPath);
// the criteria within an association node are grouped with an implicit AND
@@ -1306,8 +1306,7 @@ private String getAssociationPath() {
if (fullPath.length() > 0) fullPath.append(".");
fullPath.append(propertyName);
}
- final String associationPath = fullPath.toString();
- return associationPath;
+ return fullPath.toString();
}
private boolean isCriteriaConstructionMethod(String name, Object[] args) {
@@ -14,18 +14,9 @@
*/
package org.codehaus.groovy.grails.orm.hibernate.cfg;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.codehaus.groovy.grails.commons.AnnotationDomainClassArtefactHandler;
-import org.codehaus.groovy.grails.commons.ArtefactHandler;
-import org.codehaus.groovy.grails.commons.DomainClassArtefactHandler;
-import org.codehaus.groovy.grails.commons.GrailsApplication;
-import org.codehaus.groovy.grails.commons.GrailsClass;
-import org.codehaus.groovy.grails.commons.GrailsDomainClass;
+import org.codehaus.groovy.grails.commons.*;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.SessionFactory;
@@ -35,6 +26,10 @@
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.engine.FilterDefinition;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* Allows configuring Grails' hibernate support to work in conjuntion with Hibernate's annotation
* support.
@@ -132,6 +127,8 @@ public SessionFactory buildSessionFactory() throws HibernateException {
*/
@Override
protected void secondPassCompile() throws MappingException {
+ final Thread currentThread = Thread.currentThread();
+ final ClassLoader originalContextLoader = currentThread.getContextClassLoader();
if (!configLocked) {
if (LOG.isDebugEnabled()) {
LOG.debug("[GrailsAnnotationConfiguration] [" + domainClasses.size() + "] Grails domain classes to bind to persistence runtime");
@@ -145,7 +142,7 @@ protected void secondPassCompile() throws MappingException {
final String fullClassName = domainClass.getFullName();
String hibernateConfig = fullClassName.replace('.', '/') + ".hbm.xml";
- final ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ final ClassLoader loader = originalContextLoader;
// don't configure Hibernate mapped classes
if (loader.getResource(hibernateConfig) != null) continue;
@@ -159,7 +156,14 @@ protected void secondPassCompile() throws MappingException {
}
}
- super.secondPassCompile();
+
+ try {
+ currentThread.setContextClassLoader(grailsApplication.getClassLoader());
+ super.secondPassCompile();
+ } finally {
+ currentThread.setContextClassLoader(originalContextLoader);
+
+ }
configLocked = true;
}
Oops, something went wrong.

0 comments on commit 2a525be

Please sign in to comment.