Skip to content

Commit

Permalink
Add Hibernate 5 build
Browse files Browse the repository at this point in the history
  • Loading branch information
timowest committed Dec 11, 2015
1 parent 601608e commit 524189a
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 65 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ addons:
postgresql: "9.3"
env:
matrix:
- MODULE=!querydsl-scala
- MODULE=querydsl-scala
- MODULE=!querydsl-scala PROFILES=all,travis,examples
- MODULE=!querydsl-jpa-codegen PROFILES=jpa,hibernate5,travis,examples
- MODULE=querydsl-scala PROFILES=all,travis
install:
- mvn -B -q install -DskipTests=true
- mvn -B -q install -P${PROFILES} -DskipTests=true
before_script:
- mysql -u root -e "source travis/mysql.sql"
- psql -U postgres -f travis/postgresql.sql
- psql -c 'create extension postgis;' -d querydsl -U postgres
- ./travis/cubrid.sh
- ./travis/firebird.sh
script: mvn -B test -Pall,travis,examples --projects ${MODULE} jacoco:report
script: mvn -B test -P${PROFILES} --projects ${MODULE} jacoco:report
sudo: required
after_success:
- mvn coveralls:report
15 changes: 14 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

<argLine>-Xms256m -Xmx512m</argLine>

<!-- deps -->
<!-- SQL deps -->
<derby.version>10.11.1.1</derby.version>
<hsqldb.version>2.3.2</hsqldb.version>
<h2.version>1.4.186</h2.version>
Expand All @@ -52,6 +52,11 @@
<teradata.version>13.10.00.35</teradata.version>
<firebird.version>2.2.5</firebird.version>

<!-- JPA deps -->
<hibernate.version>4.3.11.Final</hibernate.version>
<hibernate.validator.version>4.3.1.Final</hibernate.validator.version>
<eclipselink.version>2.6.0-RC1</eclipselink.version>

<guava.version>18.0</guava.version>
<codegen.version>0.6.8</codegen.version>
<mysema.lang.version>0.2.4</mysema.lang.version>
Expand Down Expand Up @@ -563,6 +568,14 @@
</modules>
</profile>

<profile>
<id>hibernate5</id>
<properties>
<hibernate.version>5.0.3.Final</hibernate.version>
<hibernate.validator.version>5.2.2.Final</hibernate.validator.version>
</properties>
</profile>

<profile>
<id>jdo</id>
<modules>
Expand Down
2 changes: 0 additions & 2 deletions querydsl-examples/querydsl-example-jpa-guice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failIfNoTests>false</failIfNoTests>

<hibernate.version>4.1.7.Final</hibernate.version>
<hibernate.validator.version>4.3.0.Final</hibernate.validator.version>
<guice.version>3.0</guice.version>
<h2.version>1.3.170</h2.version>
</properties>
Expand Down
14 changes: 7 additions & 7 deletions querydsl-jpa-codegen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
<developerConnection>${project.checkout}</developerConnection>
<url>${project.githubpage}</url>
</scm>

<properties>
<hibernate.version>4.1.7.Final</hibernate.version>
<hibernate.validator.version>4.3.0.Final</hibernate.validator.version>
<hibernate4.version>4.1.7.Final</hibernate4.version>
<hibernate4.validator.version>4.3.0.Final</hibernate4.validator.version>
</properties>

<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
<version>${hibernate4.version}</version>
<exclusions>
<exclusion>
<groupId>cglib</groupId>
Expand All @@ -47,13 +47,13 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
<version>${hibernate4.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate.validator.version}</version>
<version>${hibernate4.validator.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand Down
11 changes: 7 additions & 4 deletions querydsl-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
</scm>

<properties>
<hibernate.version>4.3.11.Final</hibernate.version>
<hibernate.validator.version>4.3.1.Final</hibernate.validator.version>
<eclipselink.version>2.6.0-RC1</eclipselink.version>
<osgi.import.package>javax.persistence.*;version="[1.1,3)",${osgi.import.package.root}</osgi.import.package>
</properties>

Expand Down Expand Up @@ -63,7 +60,13 @@
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>2.2.4</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.spi.ViolatedConstraintNameExtracter;
import org.hibernate.type.StandardBasicTypes;

/**
Expand Down Expand Up @@ -158,27 +156,22 @@ public String getAddColumnString() {
return "Add";
}

@Override
public boolean supportsTemporaryTables() {
return true;
}

@Override
public String getCreateTemporaryTableString() {
return "create global temporary table";
}

@Override
public String getCreateTemporaryTablePostfix() {
return " on commit preserve rows";
}

@Override
public Boolean performTemporaryTableDDLInIsolation() {
return Boolean.TRUE;
}

@Override
public boolean dropTemporaryTableAfterUse() {
return false;
}
Expand Down Expand Up @@ -304,41 +297,42 @@ public boolean supportsBindAsCallableArgument() {
return false;
}

@Override
public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
return EXTRACTER;
}

private static final ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {

/**
* Extract the name of the violated constraint from the given
* SQLException.
*
* @param sqle
* The exception that was the result of the constraint
* violation.
* @return The extracted constraint name.
*/
@Override
public String extractConstraintName(SQLException sqle) {
String constraintName = null;

int errorCode = sqle.getErrorCode();
if (errorCode == 27003) {
constraintName = extractUsingTemplate("Unique constraint (", ") violated.",
sqle.getMessage());
}

if (constraintName != null) {
int i = constraintName.indexOf('.');
if (i != -1) {
constraintName = constraintName.substring(i + 1);
}
}
return constraintName;
}
};
// @Override
// public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
// return EXTRACTER;
// }
//
// private static final ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
//
// /**
// * Extract the name of the violated constraint from the given
// * SQLException.
// *
// * @param sqle
// * The exception that was the result of the constraint
// * violation.
// * @return The extracted constraint name.
// */
// @Override
// public String extractConstraintName(SQLException sqle) {
// String constraintName = null;
//
// int errorCode = sqle.getErrorCode();
// if (errorCode == 27003) {
// constraintName = extractUsingTemplate("Unique constraint (", ") violated.",
// sqle.getMessage());
// }
//
// if (constraintName != null) {
// int i = constraintName.indexOf('.');
// if (i != -1) {
// constraintName = constraintName.substring(i + 1);
// }
// }
// return constraintName;
// }
//
// };

@Override
public boolean supportsNotNullUnique() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
import org.junit.rules.MethodRule;
import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
Expand Down Expand Up @@ -107,7 +107,7 @@ private void start() throws Exception {
throw new IllegalArgumentException("No configuration available at classpath:" + mode);
}
props.load(is);
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder()
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
.applySettings(props)
.build();
cfg.setProperties(props);
Expand All @@ -119,9 +119,7 @@ private void start() throws Exception {
private void shutdown() {
if (session != null) {
try {
if (session.getTransaction().isActive()) {
session.getTransaction().rollback();
}
session.getTransaction().rollback();
} finally {
session.close();
session = null;
Expand Down

0 comments on commit 524189a

Please sign in to comment.