Merge remote-tracking branch 'upstream/master' into wip/6.0_merge_34
This commit is contained in:
commit
a0b4566264
|
@ -65,8 +65,8 @@ task release {
|
|||
"the fact that subprojects will appropriately define a release task " +
|
||||
"themselves if they have any release-related activities to perform"
|
||||
|
||||
// Force to release with JDK 8. Releasing with JDK 11 is not supported yet:
|
||||
// - the hibernate-orm-modules tests do not run due to an issue with the ASM version currently used by Gradle
|
||||
// Force to release with JDK 8. It used to not work on JDK11 because of the hibernate-orm-modules module,
|
||||
// but this limitation might be resolved now that this module has been deleted?
|
||||
doFirst {
|
||||
if ( !JavaVersion.current().isJava8() || !gradle.ext.testedJavaVersionAsEnum.isJava8() ) {
|
||||
throw new IllegalStateException( "Please use JDK 8 to perform the release." )
|
||||
|
|
|
@ -15,7 +15,6 @@ ext {
|
|||
'hibernate-infinispan',
|
||||
'hibernate-ehcache',
|
||||
'hibernate-java8',
|
||||
'hibernate-orm-modules',
|
||||
'hibernate-integrationtest-java-modules',
|
||||
'release'
|
||||
]
|
||||
|
|
|
@ -4,321 +4,14 @@
|
|||
|
||||
The http://wildfly.org/[WildFly application server] includes Hibernate ORM as the default JPA provider out of the box.
|
||||
|
||||
This means that you don't need to package Hibernate ORM with the applications you deploy on WildFly,
|
||||
instead the application server will automatically enable Hibernate support if it detects that your application is using JPA.
|
||||
In previous versions of Hibernate ORM, we offered a "feature pack" to enable anyone to use the very latest version in
|
||||
WildFly as soon as a new release of Hibernate ORM was published.
|
||||
|
||||
You can also benefit from these modules when not using JPA, to avoid including Hibernate ORM and all its
|
||||
dependencies into your deployment.
|
||||
This will require activating the module explicitly using a `jboss-deployment-structure.xml` file or a Manifest entry:
|
||||
see https://docs.jboss.org/author/display/WFLY/Class+Loading+in+WildFly[Class Loading in WildFly] for some examples.
|
||||
|
||||
Often a newer version of Hibernate ORM is available than the one coming with a given WildFly release; to make sure
|
||||
you can enjoy the latest version of Hibernate on any reasonably recent WildFly edition we publish _WildFly feature packs_, these can be used with various WildFly provisioning tools to create a custom server with a different
|
||||
version of Hibernate ORM.
|
||||
|
||||
== What is a WildFly feature pack
|
||||
|
||||
WildFly is a runtime built on https://jboss-modules.github.io/jboss-modules/manual/[JBoss Modules]; this is a light weight and efficient modular classloader which allows the different components of a modern server to be defined as independent modules.
|
||||
|
||||
Hibernate ORM and its components are defined as one such module; this implies you can even have multiple different versions of an Hibernate ORM module in the same runtime while having their classpaths isolated from each other: you can add the very latest Hibernate ORM releases to WildFly without having to remove the existing copy.
|
||||
|
||||
This gives you the flexibility to use the latest version for one of your application with the peace of mind that you won't break other applications requiring a different version of Hibernate. We don't generally recommend to abuse this system but it's often useful to be able for example to upgrade and test one application at a time, rather than having to mandate a new version for multiple services and have to update them all in one shot.
|
||||
|
||||
A feature pack is a zip file containing some XML files which define the structure of the JBoss Module(s) and list the Java "jar" files which will be needed by identifying them via Maven coordinates.
|
||||
|
||||
This has some further benefits:
|
||||
|
||||
- A feature pack is very small as it's just a zipped file with some lines of XML.
|
||||
- In terms of disk space you can build a "thin" server which doesn't actually include a copy of your Maven artifacts but just loads the classes on demand from your local Maven cache.
|
||||
- You still have the option to build a "full" server so that it can be re-distributed without needing to copy a local Maven repository.
|
||||
- When using the provisioning tool you benefit from a composable approach, so N different packs can be combined to form a custom server.
|
||||
- Since the feature pack XML merely lists which artifacts are recommended (rather than including a binary copy) it is easy to override the exact versions; this is ideal to apply micro, urgent fixes.
|
||||
- A feature pack can declare transitive dependencies on other feature packs, so you will automatically be provided all non-optional dependencies of Hibernate ORM.
|
||||
|
||||
It is also interesting to highlight what it is not: differently than most build systems, the focus of JBoss Modules is not on how a project is built but how it should be run.
|
||||
|
||||
An important aspect is that runtime dependencies of a JBoss Module are *not transitive*: so for example if the latest Hibernate ORM requires Byte Buddy version 5 (as an example) while any other module that your application needs depends on Byte Buddy version 6 this will not be a problem.
|
||||
|
||||
Upgrading your applications could not be easier, as you won't have to ensure that all your dependencies are aligned to use the same versions.
|
||||
|
||||
|
||||
== How to get the latest Hibernate ORM feature pack for WildFly
|
||||
|
||||
The feature pack can be downloaded from Maven Central, to facilitate automatic unpacking during your build.
|
||||
Such a feature pack is released whenever any new version of Hibernate ORM is released.
|
||||
|
||||
.Maven identifier for the WildFly feature pack
|
||||
|
||||
====
|
||||
[source, XML]
|
||||
[subs="verbatim,attributes"]
|
||||
----
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-orm-jbossmodules</artifactId>
|
||||
<version>{fullVersion}</version>
|
||||
----
|
||||
====
|
||||
|
||||
Typically you won't download this file directly but you will use either a Maven plugin or a Gradle plugin to build the custom WildFly server.
|
||||
|
||||
== Create a Provisioning Configuration File
|
||||
|
||||
You will need a small XML file to define which feature packs you want to assemble.
|
||||
|
||||
The following example will create a full WildFly server but also include a copy of the latest Hibernate ORM modules:
|
||||
|
||||
|
||||
.Example Provisioning Configuration File
|
||||
====
|
||||
[source, XML]
|
||||
[subs="verbatim,attributes"]
|
||||
----
|
||||
<server-provisioning xmlns="urn:wildfly:server-provisioning:1.1" copy-module-artifacts="true">
|
||||
<feature-packs>
|
||||
<feature-pack
|
||||
groupId="org.hibernate"
|
||||
artifactId="hibernate-orm-jbossmodules"
|
||||
version="${hibernate-orm.version}" />
|
||||
<feature-pack
|
||||
groupId="org.wildfly"
|
||||
artifactId="wildfly-feature-pack"
|
||||
version="${wildfly.version}" />
|
||||
</feature-packs>
|
||||
</server-provisioning>
|
||||
----
|
||||
====
|
||||
|
||||
Of course should you wish your custom server to have more features you can list additional feature packs.
|
||||
|
||||
It is also possible to build a "thin" server by not setting the _copy-module-artifacts_ flag, or you can further customize and filter out things you want removed.
|
||||
|
||||
See https://github.com/wildfly/wildfly-build-tools[the README of the WildFly Build Tools project] on Github for more details.
|
||||
|
||||
Next you can use either the https://github.com/wildfly/wildfly-build-tools[Maven plugin] or the https://plugins.gradle.org/plugin/org.wildfly.build.featurepack[Gradle plugin] to actually create a fresh copy of your custom server.
|
||||
|
||||
== Maven users: invoke the WildFly Provisioning Plugin
|
||||
|
||||
Assuming the previous Provisioning Configuration File is saved as `server-provisioning.xml`, you will just have to refer the plugin to it, pick an output directory name and bing the plugin to the build lifecycle.
|
||||
|
||||
.Example Maven Provisioning
|
||||
====
|
||||
[source, XML]
|
||||
----
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.wildfly.build</groupId>
|
||||
<artifactId>wildfly-server-provisioning-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>server-provisioning</id>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
<phase>compile</phase>
|
||||
<configuration>
|
||||
<config-file>server-provisioning.xml</config-file>
|
||||
<server-name>wildfly-custom</server-name>
|
||||
</configuration>
|
||||
</execution>
|
||||
----
|
||||
====
|
||||
|
||||
==== JPA version override
|
||||
|
||||
With WildFly 12 being built with JavaEE7 in mind, it ships the JPA 2.1 API.
|
||||
|
||||
Hibernate ORM 5.3 requires JPA 2.2, and it is not possible at this time to replace the JPA API using the Maven provisioning plugin so you'll have to apply a "WildFly patch" as well.
|
||||
|
||||
A WildFly patch can be applied from the WildFly CLI; here we show how to automate it all with Maven plugins.
|
||||
|
||||
.Example Maven script to patch the JPA version in WildFly:
|
||||
====
|
||||
[source, XML]
|
||||
----
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>fetch-jpa-patch</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.hibernate.javax.persistence</groupId>
|
||||
<artifactId>hibernate-jpa-api-2.2-wildflymodules</artifactId>
|
||||
<classifier>wildfly-12.0.0.Final-patch</classifier>
|
||||
<version>1.0.0.Beta2</version>
|
||||
<type>zip</type>
|
||||
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||
<overWrite>true</overWrite>
|
||||
<destFileName>hibernate-jpa-api-2.2-wildflymodules-patch.zip</destFileName>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.wildfly.plugins</groupId>
|
||||
<artifactId>wildfly-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>apply-wildfly-jpa22-patch-file</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
<goals>
|
||||
<goal>execute-commands</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<offline>true</offline>
|
||||
<jbossHome>${jbossHome.provisionedPath}</jbossHome>
|
||||
<!-- The CLI script below will fail if the patch was already applied in a previous build -->
|
||||
<fail-on-error>false</fail-on-error>
|
||||
<commands>
|
||||
<command>patch apply --override-all ${project.build.directory}/hibernate-jpa-api-2.2-wildflymodules-patch.zip</command>
|
||||
</commands>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
----
|
||||
====
|
||||
|
||||
== Gradle users: invoke the WildFly Provisioning plugin
|
||||
|
||||
A Gradle plugin is also available, and in this case it will take just a couple of lines.
|
||||
|
||||
Remember when creating a "thin server": the WildFly classloader will not be able to load jars from the local Gradle cache: this might trigger a second download as it looks into local Maven repositories exclusively.
|
||||
Especially if you are developing additional feature packs using Gradle, make sure to publish them into a Maven repository so that WildFly can load them.
|
||||
|
||||
Follows a full Gradle build script; in contrast to the previous Maven example which is incomplete to keep it short, is a fully working build script. Also it won't require to apply additional patches to replace the JPA version.
|
||||
|
||||
.Example Gradle Provisioning
|
||||
====
|
||||
[source, Groovy]
|
||||
----
|
||||
plugins {
|
||||
id "org.wildfly.build.provision" version '0.0.6'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven {
|
||||
name 'jboss-public'
|
||||
url 'https://repository.jboss.org/nexus/content/groups/public/'
|
||||
}
|
||||
}
|
||||
|
||||
provision {
|
||||
//Optional destination directory:
|
||||
destinationDir = file("wildfly-custom")
|
||||
|
||||
//Update the JPA API:
|
||||
override( 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api' ) {
|
||||
groupId = 'javax.persistence'
|
||||
artifactId = 'javax.persistence-api'
|
||||
version = '2.2'
|
||||
}
|
||||
configuration = file( 'wildfly-server-provisioning.xml' )
|
||||
//Define variables which need replacing in the provisioning configuration!
|
||||
variables['wildfly.version'] = '12.0.0.Final'
|
||||
variables['hibernate-orm.version'] = '5.3.0.Final'
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
you could paste this into a new file named `build.gradle` in an empty directory, then invoke:
|
||||
|
||||
gradle provision
|
||||
|
||||
and you'll have a full WildFly 12.0.0.Final server generated in the `wildfly-custom` subdirectory, including a copy of Hibernate ORM version 5.3.0.Final (in addition to the any other version that WildFly normally includes).
|
||||
|
||||
|
||||
==== A note on repositories:
|
||||
|
||||
mavenLocal()::
|
||||
strictly not necessary but will make your builds much faster if you run it more than once.
|
||||
jboss-nexus::
|
||||
This additional repository is required. Most components of WildFly are available in Maven Central but there are some occasional exceptions.
|
||||
|
||||
==== The JPA version override
|
||||
|
||||
The JPA API is a fundamental component of the application server as it is used to integrate with various other standards; at this stage while the feature packs offer some degree of composability it is not yet possible
|
||||
to have additional, independent copies of the JPA API: it needs to be replaced.
|
||||
|
||||
Hibernate ORM 5.3.0 requires JPA 2.2, yet WildFly 12 ships with JPA version 2.1. Luckily this provisioning tool is also able to override any artifact resolution.
|
||||
|
||||
Of course when future versions of WildFly will be based on JPA 2.2, this step might soon no longer be necessary.
|
||||
|
||||
|
||||
== WildFly module identifiers: slots and conventions
|
||||
|
||||
Note that the Hibernate ORM modules coming with WildFly will remain untouched: you can switch between the original version and the new version from the ZIP file as needed as a matter of configuration. Different applications can use different versions.
|
||||
|
||||
The application server identifies modules using a name and a _slot_.
|
||||
By default, the module _org.hibernate:main_ will be used to provide JPA support for given deployments: _main_ is the default slot and represents the copy of Hibernate ORM coming with WildFly itself.
|
||||
|
||||
By convention all modules included with WildFly use the "main" slot, while the modules released by the Hibernate project
|
||||
will use a slot name which matches the version, and also provide an alias to match its "major.minor" version.
|
||||
|
||||
Our suggestion is to depend on the module using the "major.minor" representation, as this simplifies rolling out bugfix
|
||||
releases (micro version updates) of Hibernate ORM without changing application configuration (micro versions are always expected to be backward compatible and released as bugfix only).
|
||||
|
||||
For example, if your application wants to use the latest version of Hibernate ORM version {majorMinorVersion}.x it should declare to use the module _org.hibernate:{majorMinorVersion}_. You can of course decide to use the full version instead for more precise control, in case an application requires a very specific version.
|
||||
|
||||
== Switch to a different Hibernate ORM slot
|
||||
|
||||
In order to use a different module other than the default _org.hibernate:main_ specify the identifier of the module you wish to use via the `jboss.as.jpa.providerModule` property in the _persistence.xml_ file of your application, as in the following example.
|
||||
|
||||
[[wildfly-using-custom-hibernate-orm-version]]
|
||||
.Using an alternative module slot of Hibernate ORM
|
||||
====
|
||||
[source, XML]
|
||||
[subs="verbatim,attributes"]
|
||||
----
|
||||
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
|
||||
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
|
||||
version="2.1" >
|
||||
|
||||
<persistence-unit name="examplePu">
|
||||
|
||||
<!-- ... -->
|
||||
|
||||
<properties>
|
||||
<property name="jboss.as.jpa.providerModule" value="org.hibernate:{majorMinorVersion}"/>
|
||||
</properties>
|
||||
|
||||
<!-- ... -->
|
||||
|
||||
</persistence-unit>
|
||||
</persistence>
|
||||
----
|
||||
====
|
||||
|
||||
Needless to say, this will affect the classpath of your application: if your single application declares multiple
|
||||
persistence units, they should all make a consistent choice!
|
||||
|
||||
This property is documented in the https://docs.jboss.org/author/display/WFLY/JPA+Reference+Guide[WildFly JPA Reference Guide];
|
||||
you might want to check it out as it lists several other useful properties.
|
||||
|
||||
== Limitations of using the custom WildFly modules
|
||||
|
||||
When using the custom modules provided by the feature packs you're going to give up on some of the integration which the application server normally automates.
|
||||
|
||||
For example, enabling an Infinispan 2nd level cache is straight forward when using the default Hibernate ORM
|
||||
module, as WildFly will automatically setup the dependency to the Infinispan and clustering components.
|
||||
When using these custom modules such integration will no longer work automatically: you can still
|
||||
enable all normally available features but these will require explicit configuration, as if you were
|
||||
running Hibernate in a different container, or in no container.
|
||||
|
||||
You might be able to get a matching feature pack from the Infinispan or Ehcache projects, you can create a module yourself (after all it's just a simple XML file), or you can just add such additional dependencies in your application as in the old days: modules and feature packs give you some advantages but good old-style jars are also still a viable option.
|
||||
|
||||
Needless to say, those users not interested in having the very latest versions can just use the versions integrated in WildFly and benefit from the library combinations carefully tested by the WildFly team.
|
||||
Unfortunately, since version 5.5 is upgrading to JPA 3.0 and targets integration with components of the Jakarta
|
||||
EE 9 stack, such feature had to be disabled.
|
||||
|
||||
As soon as WildFly releases a Jakarta EE 9 compatible server it might be possible to re-introduce such a feature, but
|
||||
we can't guarantee that we will do this as the server changed the tooling to define such packs.
|
||||
|
||||
As usual, please let us know how important this is for you, and while we'll gladly help to make this happen we might need
|
||||
to rely on volunteers to help by contributing patches, testing it out and providing feedback.
|
||||
|
|
|
@ -229,7 +229,6 @@ sourceSets {
|
|||
include '*.xml'
|
||||
include '**/*.properties'
|
||||
include '**/*.xml'
|
||||
exclude 'src/test/resources/arquillian.xml'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,12 +34,10 @@ ext {
|
|||
|
||||
geolatteVersion = '1.4.0'
|
||||
|
||||
// Wildfly version targeted by module ZIP; Arquillian/Shrinkwrap versions used for CDI testing and testing the module ZIP
|
||||
// Wildfly version targeted by the custom Jipijapa build
|
||||
wildflyVersion = '17.0.1.Final'
|
||||
arquillianVersion = '1.4.1.Final'
|
||||
shrinkwrapVersion = '1.2.6'
|
||||
shrinkwrapDescriptorsVersion = '2.0.0'
|
||||
wildflyArquillianContainerVersion = '2.2.0.Final'
|
||||
|
||||
jodaTimeVersion = '2.3'
|
||||
|
||||
|
@ -167,17 +165,13 @@ ext {
|
|||
|
||||
assertj: "org.assertj:assertj-core:${assertjVersion}",
|
||||
|
||||
// Arquillian/Shrinkwrap
|
||||
arquillian_junit_container: "org.jboss.arquillian.junit:arquillian-junit-container:${arquillianVersion}",
|
||||
arquillian_protocol_servlet: "org.jboss.arquillian.protocol:arquillian-protocol-servlet:${arquillianVersion}",
|
||||
|
||||
// Shrinkwrap
|
||||
shrinkwrap_api: "org.jboss.shrinkwrap:shrinkwrap-api:${shrinkwrapVersion}",
|
||||
shrinkwrap: "org.jboss.shrinkwrap:shrinkwrap-impl-base:${shrinkwrapVersion}",
|
||||
|
||||
shrinkwrap_descriptors_api_javaee: "org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-api-javaee:${shrinkwrapDescriptorsVersion}",
|
||||
shrinkwrap_descriptors_impl_javaee: "org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-impl-javaee:${shrinkwrapDescriptorsVersion}",
|
||||
|
||||
wildfly_arquillian_container_managed: "org.wildfly.arquillian:wildfly-arquillian-container-managed:${wildflyArquillianContainerVersion}",
|
||||
jboss_vfs: "org.jboss:jboss-vfs:3.2.11.Final",
|
||||
jipijapa_spi: "org.wildfly:jipijapa-spi:${wildflyVersion}",
|
||||
wildfly_transaction_client : 'org.wildfly.transaction:wildfly-transaction-client:1.1.7.Final',
|
||||
|
|
|
@ -100,10 +100,7 @@ dependencies {
|
|||
testCompile( libraries.jodaTime )
|
||||
testCompile( libraries.assertj )
|
||||
|
||||
testCompile( libraries.cdi ) {
|
||||
// we need to force it to make sure we influence the one coming from arquillian
|
||||
force=true
|
||||
}
|
||||
testCompile( libraries.cdi )
|
||||
|
||||
testCompile( libraries.validator ) {
|
||||
// for test runtime
|
||||
|
@ -125,11 +122,8 @@ dependencies {
|
|||
|
||||
testAnnotationProcessor( project( ':hibernate-jpamodelgen' ) )
|
||||
|
||||
testCompile libraries.arquillian_junit_container
|
||||
testCompile libraries.arquillian_protocol_servlet
|
||||
testCompile libraries.shrinkwrap_descriptors_api_javaee
|
||||
testCompile libraries.shrinkwrap_descriptors_impl_javaee
|
||||
testCompile libraries.wildfly_arquillian_container_managed
|
||||
|
||||
testCompile libraries.jboss_ejb_spec_jar
|
||||
testCompile libraries.jboss_annotation_spec_jar
|
||||
|
@ -282,28 +276,6 @@ task generateEnversStaticMetamodel(
|
|||
// put static metamodel classes back out to the source tree since they're version controlled.
|
||||
destinationDir = new File( "${projectDir}/src/main/java" )
|
||||
}
|
||||
//
|
||||
//if ( JavaVersion.current().isJava9Compatible() ) {
|
||||
// logger.warn( '[WARN] Skipping Javassist-related tests for hibernate-core due to Javassist JDK 9 incompatibility' )
|
||||
//
|
||||
// // we need to exclude tests using Javassist enhancement, which does not properly support
|
||||
// // Java 9 yet - https://issues.jboss.org/browse/JASSIST-261
|
||||
// test {
|
||||
// // rather than wild-cards, keep an explicit list
|
||||
// exclude 'org/hibernate/jpa/test/enhancement/InterceptFieldClassFileTransformerTest.class'
|
||||
// exclude 'org/hibernate/jpa/test/enhancement/runtime/JpaRuntimeEnhancementTest.class'
|
||||
// exclude 'org/hibernate/test/bytecode/enhancement/EnhancerTest.class'
|
||||
// exclude 'org/hibernate/test/bytecode/enhancement/basic/BasicInSessionTest.class'
|
||||
//
|
||||
// // also, any tests using Arquillian for in-container testing with WildFly currently
|
||||
// // need to be excluded because WildFly does not yet work with Java 9
|
||||
// exclude 'org/hibernate/test/wf/ddl/**'
|
||||
// exclude 'org/hibernate/jpa/test/cdi/**'
|
||||
// exclude 'org/hibernate/envers/internal/tools/MapProxyTest.class'
|
||||
// exclude 'org/hibernate/envers/test/integration/components/dynamic/AuditedDynamicComponentTest.class'
|
||||
// exclude 'org/hibernate/envers/test/integration/components/dynamic/AuditedDynamicComponentsAdvancedCasesTest.class'
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.jpa.test.cdi.extended;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.Archive;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.JavaArchive;
|
||||
import org.jboss.shrinkwrap.descriptor.api.Descriptors;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceDescriptor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
|
||||
public class ConversationalPersistenceContextExtendedTest {
|
||||
|
||||
@Deployment
|
||||
public static Archive<?> buildDeployment() {
|
||||
return ShrinkWrap.create( JavaArchive.class, "test.jar" )
|
||||
.addClass( Event.class )
|
||||
.addClass( ConversationalEventManager.class )
|
||||
.addAsManifestResource( EmptyAsset.INSTANCE, "beans.xml" )
|
||||
.addAsManifestResource( new StringAsset( persistenceXml().exportAsString() ), "persistence.xml" );
|
||||
}
|
||||
|
||||
private static PersistenceDescriptor persistenceXml() {
|
||||
return Descriptors.create( PersistenceDescriptor.class )
|
||||
.createPersistenceUnit().name( "pu-beans-basic" )
|
||||
.clazz( Event.class.getName() )
|
||||
.excludeUnlistedClasses( true )
|
||||
.nonJtaDataSource( "java:jboss/datasources/ExampleDS" )
|
||||
.getOrCreateProperties().createProperty().name( "jboss.as.jpa.providerModule" ).value( "org.hibernate:5.3" ).up().up()
|
||||
.getOrCreateProperties().createProperty().name( "hibernate.hbm2ddl.auto" ).value( "create-drop" ).up().up().up();
|
||||
}
|
||||
|
||||
@EJB
|
||||
private ConversationalEventManager eventManager;
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testIt() throws Exception {
|
||||
Event event = eventManager.saveEvent( "Untold" );
|
||||
assertEquals(0, ((Number) em.createNativeQuery( "select count(*) from Event" ).getSingleResult()).intValue());
|
||||
eventManager.endConversation();
|
||||
assertEquals(1, ((Number) em.createNativeQuery( "select count(*) from Event" ).getSingleResult()).intValue());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.jpa.test.cdi.extended;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.Archive;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.JavaArchive;
|
||||
import org.jboss.shrinkwrap.descriptor.api.Descriptors;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceDescriptor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
|
||||
public class ManualFlushConversationalPersistenceContextExtendedTest {
|
||||
|
||||
@Deployment
|
||||
public static Archive<?> buildDeployment() {
|
||||
return ShrinkWrap.create( JavaArchive.class, "test.jar" )
|
||||
.addClass( Event.class )
|
||||
.addClass( ManualFlushConversationalEventManager.class )
|
||||
.addAsManifestResource( EmptyAsset.INSTANCE, "beans.xml" )
|
||||
.addAsManifestResource( new StringAsset( persistenceXml().exportAsString() ), "persistence.xml" );
|
||||
}
|
||||
|
||||
private static PersistenceDescriptor persistenceXml() {
|
||||
return Descriptors.create( PersistenceDescriptor.class )
|
||||
.createPersistenceUnit().name( "pu-beans-basic" )
|
||||
.clazz( Event.class.getName() )
|
||||
.excludeUnlistedClasses( true )
|
||||
.nonJtaDataSource( "java:jboss/datasources/ExampleDS" )
|
||||
.getOrCreateProperties().createProperty().name( "jboss.as.jpa.providerModule" ).value( "org.hibernate:5.3" ).up().up()
|
||||
.getOrCreateProperties().createProperty().name( "hibernate.hbm2ddl.auto" ).value( "create-drop" ).up().up().up();
|
||||
}
|
||||
|
||||
@EJB
|
||||
private ManualFlushConversationalEventManager eventManager;
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-11019" )
|
||||
public void testIt() throws Exception {
|
||||
Event event = eventManager.saveEvent( "Untold" );
|
||||
//This is going to be fixed by HHH-11019 since we could rely on FlushMode to implement long conversations properly
|
||||
assertEquals(1, ((Number) em.createNativeQuery( "select count(*) from Event" ).getSingleResult()).intValue());
|
||||
eventManager.endConversation();
|
||||
assertEquals(1, ((Number) em.createNativeQuery( "select count(*) from Event" ).getSingleResult()).intValue());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.jpa.test.cdi.extended;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.Archive;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.JavaArchive;
|
||||
import org.jboss.shrinkwrap.descriptor.api.Descriptors;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceDescriptor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
|
||||
public class NonConversationalPersistenceContextExtendedTest {
|
||||
|
||||
@Deployment
|
||||
public static Archive<?> buildDeployment() {
|
||||
return ShrinkWrap.create( JavaArchive.class, "test.jar" )
|
||||
.addClass( Event.class )
|
||||
.addClass( NonConversationalEventManager.class )
|
||||
.addAsManifestResource( EmptyAsset.INSTANCE, "beans.xml" )
|
||||
.addAsManifestResource( new StringAsset( persistenceXml().exportAsString() ), "persistence.xml" );
|
||||
}
|
||||
|
||||
private static PersistenceDescriptor persistenceXml() {
|
||||
return Descriptors.create( PersistenceDescriptor.class )
|
||||
.createPersistenceUnit().name( "pu-beans-basic" )
|
||||
.clazz( Event.class.getName() )
|
||||
.excludeUnlistedClasses( true )
|
||||
.nonJtaDataSource( "java:jboss/datasources/ExampleDS" )
|
||||
.getOrCreateProperties().createProperty().name( "jboss.as.jpa.providerModule" ).value( "org.hibernate:5.3" ).up().up()
|
||||
.getOrCreateProperties().createProperty().name( "hibernate.hbm2ddl.auto" ).value( "create-drop" ).up().up().up();
|
||||
}
|
||||
|
||||
@EJB
|
||||
private NonConversationalEventManager eventManager;
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
|
||||
@Test
|
||||
public void testIt() throws Exception {
|
||||
Event event = eventManager.saveEvent( "Untold" );
|
||||
assertEquals(1, ((Number) em.createNativeQuery( "select count(*) from Event" ).getSingleResult()).intValue());
|
||||
eventManager.endConversation();
|
||||
assertEquals(1, ((Number) em.createNativeQuery( "select count(*) from Event" ).getSingleResult()).intValue());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Entity
|
||||
public class WildFlyDdlEntity {
|
||||
@Id
|
||||
Integer id;
|
||||
String name;
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl.bmt.emf;
|
||||
|
||||
import javax.ejb.Remove;
|
||||
import javax.ejb.Stateful;
|
||||
import javax.ejb.TransactionManagement;
|
||||
import javax.ejb.TransactionManagementType;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.Persistence;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
/**
|
||||
* Arquillian "component" for testing auto-ddl execution when initiated by the "app"
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Stateful
|
||||
@TransactionManagement(TransactionManagementType.BEAN)
|
||||
public class BmtEmfStatefulBean {
|
||||
EntityManagerFactory emf;
|
||||
|
||||
@Inject
|
||||
UserTransaction utx;
|
||||
|
||||
public void start() {
|
||||
// creating the SF should run schema creation
|
||||
emf = Persistence.createEntityManagerFactory( "pu-wf-ddl" );
|
||||
}
|
||||
|
||||
@Remove
|
||||
public void stop() {
|
||||
|
||||
try {
|
||||
utx.begin();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException( "Unable to start JTA transaction via UserTransaction", e );
|
||||
}
|
||||
|
||||
try {
|
||||
// closing the SF should run the delayed schema drop delegate
|
||||
emf.close();
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
try {
|
||||
utx.rollback();
|
||||
}
|
||||
catch (Exception e1) {
|
||||
throw new RuntimeException( "Unable to rollback JTA transaction via UserTransaction", e );
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
utx.commit();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException( "Unable to commit JTA transaction via UserTransaction", e );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl.bmt.emf;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import javax.annotation.Resource;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.transaction.Transaction;
|
||||
import javax.transaction.TransactionManager;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
||||
import org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor;
|
||||
import org.hibernate.jpa.boot.internal.PersistenceXmlParser;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
|
||||
import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.arquillian.test.api.ArquillianResource;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
import org.jboss.shrinkwrap.descriptor.api.Descriptors;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceDescriptor;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceUnitTransactionType;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@RunWith( Arquillian.class )
|
||||
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
|
||||
public class DdlInWildFlyUsingBmtAndEmfTest {
|
||||
|
||||
public static final String PERSISTENCE_XML_RESOURCE_NAME = "pu-wf-ddl/persistence.xml";
|
||||
public static final String PERSISTENCE_UNIT_NAME = "pu-wf-ddl";
|
||||
|
||||
@Deployment
|
||||
public static WebArchive buildDeployment() {
|
||||
WebArchive war = ShrinkWrap.create( WebArchive.class )
|
||||
.setManifest( "org/hibernate/test/wf/ddl/manifest.mf" )
|
||||
.addClass( WildFlyDdlEntity.class )
|
||||
// .addAsManifestResource( EmptyAsset.INSTANCE, "beans.xml")
|
||||
.addAsResource( new StringAsset( persistenceXml().exportAsString() ), PERSISTENCE_XML_RESOURCE_NAME )
|
||||
.addAsResource( "org/hibernate/test/wf/ddl/log4j.properties", "log4j.properties" );
|
||||
System.out.println( war.toString(true) );
|
||||
return war;
|
||||
}
|
||||
|
||||
private static PersistenceDescriptor persistenceXml() {
|
||||
final PersistenceDescriptor pd = Descriptors.create( PersistenceDescriptor.class )
|
||||
.version( "2.1" )
|
||||
.createPersistenceUnit().name( PERSISTENCE_UNIT_NAME )
|
||||
.transactionType( PersistenceUnitTransactionType._JTA )
|
||||
.jtaDataSource( "java:jboss/datasources/ExampleDS" )
|
||||
.clazz( WildFlyDdlEntity.class.getName() )
|
||||
.excludeUnlistedClasses( true )
|
||||
.getOrCreateProperties().createProperty().name( "jboss.as.jpa.providerModule" ).value( "org.hibernate:5.3" ).up().up()
|
||||
.getOrCreateProperties().createProperty().name( "hibernate.hbm2ddl.auto" ).value( "create-drop" ).up().up()
|
||||
// this should not be needed, but...
|
||||
.getOrCreateProperties().createProperty().name( AvailableSettings.JTA_PLATFORM ).value( JBossAppServerJtaPlatform.class.getName() ).up().up()
|
||||
.up();
|
||||
|
||||
|
||||
System.out.println( "persistence.xml: " );
|
||||
pd.exportTo( System.out );
|
||||
|
||||
return pd;
|
||||
}
|
||||
|
||||
@ArquillianResource
|
||||
private InitialContext initialContext;
|
||||
|
||||
@Test
|
||||
public void testCreateThenDrop() throws Exception {
|
||||
URL persistenceXmlUrl = Thread.currentThread().getContextClassLoader().getResource( PERSISTENCE_XML_RESOURCE_NAME );
|
||||
if ( persistenceXmlUrl == null ) {
|
||||
persistenceXmlUrl = Thread.currentThread().getContextClassLoader().getResource( '/' + PERSISTENCE_XML_RESOURCE_NAME );
|
||||
}
|
||||
|
||||
assertNotNull( persistenceXmlUrl );
|
||||
|
||||
ParsedPersistenceXmlDescriptor persistenceUnit = PersistenceXmlParser.locateIndividualPersistenceUnit( persistenceXmlUrl );
|
||||
// creating the EMF causes SchemaCreator to be run...
|
||||
EntityManagerFactory emf = Bootstrap.getEntityManagerFactoryBuilder( persistenceUnit, Collections.emptyMap() ).build();
|
||||
|
||||
// closing the EMF causes the delayed SchemaDropper to be run...
|
||||
// wrap in a transaction just to see if we can get this to fail in the way the WF report says;
|
||||
// in my experience however this succeeds with or without the transaction
|
||||
final TransactionManager tm = emf.unwrap( SessionFactoryImplementor.class ).getServiceRegistry().getService( JtaPlatform.class ).retrieveTransactionManager();
|
||||
|
||||
tm.begin();
|
||||
Transaction txn = tm.getTransaction();
|
||||
emf.close();
|
||||
txn.commit();
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl.bmt.sf;
|
||||
|
||||
import javax.ejb.Remove;
|
||||
import javax.ejb.Stateful;
|
||||
import javax.ejb.TransactionManagement;
|
||||
import javax.ejb.TransactionManagementType;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.Persistence;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
|
||||
|
||||
/**
|
||||
* Arquillian "component" for testing auto-ddl execution when initiated by the "app"
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Stateful
|
||||
@TransactionManagement(TransactionManagementType.BEAN)
|
||||
public class BmtSfStatefulBean {
|
||||
private static SessionFactory sessionFactory;
|
||||
|
||||
@Inject
|
||||
UserTransaction utx;
|
||||
|
||||
public void start() {
|
||||
Configuration configuration = new Configuration();
|
||||
configuration = configuration.configure( "hibernate.cfg.xml" );
|
||||
configuration.addAnnotatedClass( WildFlyDdlEntity.class );
|
||||
|
||||
// creating the SF should run schema creation
|
||||
sessionFactory = configuration.buildSessionFactory();
|
||||
}
|
||||
|
||||
@Remove
|
||||
public void stop() {
|
||||
try {
|
||||
utx.begin();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException( "Unable to start JTA transaction via UserTransaction", e );
|
||||
}
|
||||
|
||||
try {
|
||||
// closing the SF should run the delayed schema drop delegate
|
||||
sessionFactory.close();
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
try {
|
||||
utx.rollback();
|
||||
}
|
||||
catch (Exception e1) {
|
||||
throw new RuntimeException( "Unable to rollback JTA transaction via UserTransaction", e );
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
try {
|
||||
utx.commit();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException( "Unable to commit JTA transaction via UserTransaction", e );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl.bmt.sf;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
@TestForIssue(jiraKey = "HHH-11024")
|
||||
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
|
||||
public class DdlInWildFlyUsingBmtAndSfTest {
|
||||
|
||||
public static final String ARCHIVE_NAME = BmtSfStatefulBean.class.getSimpleName();
|
||||
|
||||
public static final String hibernate_cfg = "<?xml version='1.0' encoding='utf-8'?>"
|
||||
+ "<!DOCTYPE hibernate-configuration PUBLIC " + "\"//Hibernate/Hibernate Configuration DTD 3.0//EN\" "
|
||||
+ "\"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd\">"
|
||||
+ "<hibernate-configuration><session-factory>" + "<property name=\"show_sql\">true</property>"
|
||||
+ "<property name=\"hibernate.show_sql\">true</property>"
|
||||
+ "<property name=\"hibernate.hbm2ddl.auto\">create-drop</property>"
|
||||
+ "<property name=\"hibernate.connection.datasource\">java:jboss/datasources/ExampleDS</property>"
|
||||
+ "<property name=\"hibernate.transaction.jta.platform\">JBossAS</property>"
|
||||
+ "<property name=\"hibernate.transaction.coordinator_class\">jta</property>"
|
||||
+ "<property name=\"hibernate.id.new_generator_mappings\">true</property>"
|
||||
+ "</session-factory></hibernate-configuration>";
|
||||
|
||||
@Deployment
|
||||
public static WebArchive deploy() throws Exception {
|
||||
final WebArchive war = ShrinkWrap.create( WebArchive.class, ARCHIVE_NAME + ".war" )
|
||||
.setManifest( "org/hibernate/test/wf/ddl/manifest.mf" )
|
||||
.addClasses( WildFlyDdlEntity.class )
|
||||
.addAsResource( new StringAsset( hibernate_cfg ), "hibernate.cfg.xml" )
|
||||
.addClasses( BmtSfStatefulBean.class )
|
||||
.addClasses( DdlInWildFlyUsingBmtAndSfTest.class );
|
||||
return war;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Test
|
||||
public void testCreateThenDrop(BmtSfStatefulBean ejb) throws Exception {
|
||||
assert ejb != null : "Method injected StatefulCMTBean reference was null";
|
||||
|
||||
try {
|
||||
ejb.start();
|
||||
}
|
||||
finally {
|
||||
ejb.stop();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl.cmt.emf;
|
||||
|
||||
import javax.ejb.Remove;
|
||||
import javax.ejb.Stateful;
|
||||
import javax.ejb.TransactionAttribute;
|
||||
import javax.ejb.TransactionAttributeType;
|
||||
import javax.ejb.TransactionManagement;
|
||||
import javax.ejb.TransactionManagementType;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.Persistence;
|
||||
|
||||
/**
|
||||
* Arquillian "component" for testing auto-ddl execution when initiated by the "app"
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Stateful
|
||||
@TransactionManagement(TransactionManagementType.CONTAINER)
|
||||
public class CmtEmfStatefulBean {
|
||||
EntityManagerFactory emf;
|
||||
|
||||
@TransactionAttribute(TransactionAttributeType.NEVER)
|
||||
public void start() {
|
||||
// creating the SF should run schema creation
|
||||
emf = Persistence.createEntityManagerFactory( "pu-wf-ddl" );
|
||||
}
|
||||
|
||||
@Remove
|
||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
public void stop() {
|
||||
// closing the SF should run the delayed schema drop delegate
|
||||
emf.close();
|
||||
}
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl.cmt.emf;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.transaction.Transaction;
|
||||
import javax.transaction.TransactionManager;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.transaction.jta.platform.internal.JBossAppServerJtaPlatform;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
||||
import org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor;
|
||||
import org.hibernate.jpa.boot.internal.PersistenceXmlParser;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
|
||||
import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.arquillian.test.api.ArquillianResource;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
import org.jboss.shrinkwrap.descriptor.api.Descriptors;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceDescriptor;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceUnitTransactionType;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@RunWith( Arquillian.class )
|
||||
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
|
||||
public class DdlInWildFlyUsingBmtAndEmfTest {
|
||||
|
||||
public static final String PERSISTENCE_XML_RESOURCE_NAME = "pu-wf-ddl/persistence.xml";
|
||||
public static final String PERSISTENCE_UNIT_NAME = "pu-wf-ddl";
|
||||
|
||||
@Deployment
|
||||
public static WebArchive buildDeployment() {
|
||||
WebArchive war = ShrinkWrap.create( WebArchive.class )
|
||||
.setManifest( "org/hibernate/test/wf/ddl/manifest.mf" )
|
||||
.addClass( WildFlyDdlEntity.class )
|
||||
// .addAsManifestResource( EmptyAsset.INSTANCE, "beans.xml")
|
||||
.addAsResource( new StringAsset( persistenceXml().exportAsString() ), PERSISTENCE_XML_RESOURCE_NAME )
|
||||
.addAsResource( "org/hibernate/test/wf/ddl/log4j.properties", "log4j.properties" );
|
||||
System.out.println( war.toString(true) );
|
||||
return war;
|
||||
}
|
||||
|
||||
private static PersistenceDescriptor persistenceXml() {
|
||||
final PersistenceDescriptor pd = Descriptors.create( PersistenceDescriptor.class )
|
||||
.version( "2.1" )
|
||||
.createPersistenceUnit().name( PERSISTENCE_UNIT_NAME )
|
||||
.transactionType( PersistenceUnitTransactionType._JTA )
|
||||
.jtaDataSource( "java:jboss/datasources/ExampleDS" )
|
||||
.clazz( WildFlyDdlEntity.class.getName() )
|
||||
.excludeUnlistedClasses( true )
|
||||
.getOrCreateProperties().createProperty().name( "jboss.as.jpa.providerModule" ).value( "org.hibernate:5.3" ).up().up()
|
||||
.getOrCreateProperties().createProperty().name( "hibernate.hbm2ddl.auto" ).value( "create-drop" ).up().up()
|
||||
// this should not be needed, but...
|
||||
.getOrCreateProperties().createProperty().name( AvailableSettings.JTA_PLATFORM ).value( JBossAppServerJtaPlatform.class.getName() ).up().up()
|
||||
.up();
|
||||
|
||||
|
||||
System.out.println( "persistence.xml: " );
|
||||
pd.exportTo( System.out );
|
||||
|
||||
return pd;
|
||||
}
|
||||
|
||||
@ArquillianResource
|
||||
private InitialContext initialContext;
|
||||
|
||||
@Test
|
||||
public void testCreateThenDrop() throws Exception {
|
||||
URL persistenceXmlUrl = Thread.currentThread().getContextClassLoader().getResource( PERSISTENCE_XML_RESOURCE_NAME );
|
||||
if ( persistenceXmlUrl == null ) {
|
||||
persistenceXmlUrl = Thread.currentThread().getContextClassLoader().getResource( '/' + PERSISTENCE_XML_RESOURCE_NAME );
|
||||
}
|
||||
|
||||
assertNotNull( persistenceXmlUrl );
|
||||
|
||||
ParsedPersistenceXmlDescriptor persistenceUnit = PersistenceXmlParser.locateIndividualPersistenceUnit( persistenceXmlUrl );
|
||||
// creating the EMF causes SchemaCreator to be run...
|
||||
EntityManagerFactory emf = Bootstrap.getEntityManagerFactoryBuilder( persistenceUnit, Collections.emptyMap() ).build();
|
||||
|
||||
// closing the EMF causes the delayed SchemaDropper to be run...
|
||||
// wrap in a transaction just to see if we can get this to fail in the way the WF report says;
|
||||
// in my experience however this succeeds with or without the transaction
|
||||
final TransactionManager tm = emf.unwrap( SessionFactoryImplementor.class ).getServiceRegistry().getService( JtaPlatform.class ).retrieveTransactionManager();
|
||||
|
||||
tm.begin();
|
||||
Transaction txn = tm.getTransaction();
|
||||
emf.close();
|
||||
txn.commit();
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl.cmt.sf;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
|
||||
import javax.ejb.Stateful;
|
||||
import javax.ejb.TransactionAttribute;
|
||||
import javax.ejb.TransactionAttributeType;
|
||||
import javax.ejb.TransactionManagement;
|
||||
import javax.ejb.TransactionManagementType;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
|
||||
|
||||
|
||||
@Stateful
|
||||
@TransactionManagement(TransactionManagementType.CONTAINER)
|
||||
public class CmtSfStatefulBean {
|
||||
|
||||
private static SessionFactory sessionFactory;
|
||||
|
||||
@TransactionAttribute(TransactionAttributeType.NEVER)
|
||||
public void start() {
|
||||
try {
|
||||
Configuration configuration = new Configuration();
|
||||
configuration = configuration.configure( "hibernate.cfg.xml" );
|
||||
configuration.addAnnotatedClass( WildFlyDdlEntity.class );
|
||||
|
||||
sessionFactory = configuration.buildSessionFactory();
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
System.err.println( "Initial SessionFactory creation failed." + ex );
|
||||
throw new ExceptionInInitializerError( ex );
|
||||
}
|
||||
}
|
||||
|
||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
public void stop() {
|
||||
sessionFactory.close();
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.test.wf.ddl.cmt.sf;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.test.wf.ddl.WildFlyDdlEntity;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
@TestForIssue(jiraKey = "HHH-11024")
|
||||
@Ignore( "WildFly has not released a version supporting JPA 2.2 and CDI 2.0" )
|
||||
public class DdlInWildFlyUsingCmtAndSfTest {
|
||||
|
||||
public static final String ARCHIVE_NAME = CmtSfStatefulBean.class.getSimpleName();
|
||||
|
||||
public static final String hibernate_cfg = "<?xml version='1.0' encoding='utf-8'?>"
|
||||
+ "<!DOCTYPE hibernate-configuration PUBLIC " + "\"//Hibernate/Hibernate Configuration DTD 3.0//EN\" "
|
||||
+ "\"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd\">"
|
||||
+ "<hibernate-configuration><session-factory>" + "<property name=\"show_sql\">true</property>"
|
||||
+ "<property name=\"hibernate.show_sql\">true</property>"
|
||||
+ "<property name=\"hibernate.hbm2ddl.auto\">create-drop</property>"
|
||||
+ "<property name=\"hibernate.connection.datasource\">java:jboss/datasources/ExampleDS</property>"
|
||||
+ "<property name=\"hibernate.transaction.jta.platform\">JBossAS</property>"
|
||||
+ "<property name=\"hibernate.transaction.coordinator_class\">jta</property>"
|
||||
+ "<property name=\"hibernate.id.new_generator_mappings\">true</property>"
|
||||
+ "</session-factory></hibernate-configuration>";
|
||||
|
||||
@Deployment
|
||||
public static WebArchive deploy() throws Exception {
|
||||
final WebArchive war = ShrinkWrap.create( WebArchive.class, ARCHIVE_NAME + ".war" )
|
||||
.setManifest( "org/hibernate/test/wf/ddl/manifest.mf" )
|
||||
.addClasses( WildFlyDdlEntity.class )
|
||||
.addAsResource( new StringAsset( hibernate_cfg ), "hibernate.cfg.xml" )
|
||||
.addClasses( CmtSfStatefulBean.class )
|
||||
.addClasses( DdlInWildFlyUsingCmtAndSfTest.class );
|
||||
return war;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Test
|
||||
public void testCreateThenDrop(CmtSfStatefulBean ejb) throws Exception {
|
||||
assert ejb != null : "Method injected StatefulCMTBean reference was null";
|
||||
|
||||
try {
|
||||
ejb.start();
|
||||
}
|
||||
finally {
|
||||
ejb.stop();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Package containing various tests running inside a WildFly container via Arquillian.
|
||||
*/
|
||||
package org.hibernate.test.wf;
|
|
@ -1,37 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
-->
|
||||
<arquillian
|
||||
xmlns="http://jboss.org/schema/arquillian"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
|
||||
|
||||
<defaultProtocol type="Servlet 3.0" />
|
||||
|
||||
<!-- Uncomment in order to inspect deployments -->
|
||||
<!--
|
||||
<engine>
|
||||
<property name="deploymentExportPath">${arquillianDeploymentExportDir}</property>
|
||||
</engine>
|
||||
-->
|
||||
|
||||
<group qualifier="Grid" default="true">
|
||||
<container qualifier="container.active-1" mode="suite" default="true">
|
||||
<configuration>
|
||||
<property name="jbossHome">${wildFlyInstallDir}</property>
|
||||
<!-- For Remote debugging of Wildfly add the following line to the 'javaVmArguments' section below: -->
|
||||
<!-- -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y-->
|
||||
<!-- DO NOT add comments within the property section below as the Arquillian parser can't deal with it -->
|
||||
<property name="javaVmArguments">
|
||||
-Dee8.preview.mode=true
|
||||
-Djava.net.preferIPv4Stack=true
|
||||
-Djgroups.bind_addr=127.0.0.1
|
||||
</property>
|
||||
</configuration>
|
||||
</container>
|
||||
</group>
|
||||
</arquillian>
|
|
@ -1,23 +0,0 @@
|
|||
#
|
||||
# Hibernate, Relational Persistence for Idiomatic Java
|
||||
#
|
||||
# License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
# See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
#
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
|
||||
|
||||
log4j.rootLogger=info, stdout
|
||||
|
||||
# the test that this is used for is testing DDL execution within WF,
|
||||
# so for sure we want the schema-tooling logging cranked up...
|
||||
log4j.logger.org.hibernate.SQL=debug
|
||||
log4j.logger.org.hibernate.tool.schema=trace
|
||||
log4j.logger.org.hibernate.tool.hbm2ddl=trace
|
||||
|
||||
# low-level "resource" logging is likely to be useful as well
|
||||
log4j.logger.org.hibernate.resource=trace
|
||||
|
||||
log4j.logger.org.hibernate.engine.transaction.jta=trace
|
|
@ -1 +0,0 @@
|
|||
Dependencies: org.hibernate:5.3 services
|
|
@ -1,181 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id "org.wildfly.build.provision" version '0.0.11'
|
||||
id "org.wildfly.build.featurepack" version '0.0.11'
|
||||
}
|
||||
|
||||
|
||||
|
||||
apply from: rootProject.file( 'gradle/base-information.gradle' )
|
||||
apply plugin: 'java'
|
||||
apply from: rootProject.file( 'gradle/libraries.gradle' )
|
||||
|
||||
ext {
|
||||
// NOTE : `wildflyVersion` comes from libraries.gradle...
|
||||
|
||||
// "10" for WildFly 10.x, "11" for 11.x, etc
|
||||
wildFlyMajorVersion = project.wildflyVersion.split( '\\.' )[0]
|
||||
bytebuddyVersion = project.byteBuddyVersion
|
||||
antlrVersion = project.antlrVersion
|
||||
artifactClassifier = "wildfly-${wildFlyMajorVersion}-dist"
|
||||
wildFlyInstallDir = "$rootProject.buildDir/wildfly"
|
||||
fpackStagingDir = file( "target/featurepack" ) //Target build directory for the Feature Pack
|
||||
}
|
||||
|
||||
description = "Feature Pack of Hibernate ORM modules for WildFly ${project.wildFlyMajorVersion}"
|
||||
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'org.hibernate.build.maven-repo-auth'
|
||||
apply from: rootProject.file( 'gradle/publishing-repos.gradle' )
|
||||
apply from: rootProject.file( 'gradle/publishing-pom.gradle' )
|
||||
|
||||
apply plugin: 'build-dashboard'
|
||||
apply plugin: 'project-report'
|
||||
|
||||
//project.tasks.jar.enabled = false
|
||||
//project.tasks.javadoc.enabled = false
|
||||
|
||||
evaluationDependsOn( ':hibernate-core' )
|
||||
evaluationDependsOn( ':hibernate-envers' )
|
||||
|
||||
ext {
|
||||
// NOTE : `wildflyVersion` comes from libraries.gradle...
|
||||
|
||||
// "10" for WildFly 10.x, "11" for 11.x, etc
|
||||
wildFlyMajorVersion = project.wildflyVersion.split( '\\.' )[0]
|
||||
bytebuddyVersion = project.byteBuddyVersion
|
||||
antlrVersion = project.antlrVersion
|
||||
artifactClassifier = "wildfly-${wildFlyMajorVersion}-dist"
|
||||
wildFlyInstallDir = "$rootProject.buildDir/wildfly"
|
||||
fpackStagingDir = file( "target/featurepack" ) //Target build directory for the Feature Pack
|
||||
}
|
||||
|
||||
description = "Feature Pack of Hibernate ORM modules for WildFly ${project.wildFlyMajorVersion}"
|
||||
|
||||
configurations {
|
||||
featurePack {
|
||||
description = "Dependencies to be included in the published Feature Pack"
|
||||
}
|
||||
provisioning {
|
||||
description = "Dependencies which should be made available to the provisioning of WildFly"
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven {
|
||||
name 'jboss-public'
|
||||
url 'https://repository.jboss.org/nexus/content/groups/public/'
|
||||
}
|
||||
}
|
||||
|
||||
//This builds the WildFly Feature Packs which define the Hibernate ORM modules
|
||||
// # Definitions of the modules are in /module-templates
|
||||
// # Versions of the included libraries are defined in the "featurePack" configuration (below)
|
||||
// # See the "variables" option to replace tokens in the module definitions
|
||||
// # This just creates the exploded feature pack: does NOT create a zip nor a publication, which are handled by other tasks below.
|
||||
featurepack {
|
||||
moduleTemplates = file( 'module-templates' ) //where to find the templates for module.xml files to generate
|
||||
destinationDir = project.fpackStagingDir
|
||||
configurationName 'featurePack'
|
||||
// Variables to be replaced in the template. N.B. not all variables need to be replaced!
|
||||
// Exact ORM version, e.g. "5.3.0.Final"
|
||||
variables['slot'] = rootProject.ormVersion.fullName
|
||||
// Just the minor ORM version, e.g. "5.3"; Is used as an alias for the exact version
|
||||
variables['minorSlot'] = rootProject.ormVersion.family
|
||||
variables['bytebuddySlot'] = antlrVersion
|
||||
variables['antlrSlot'] = '4.7.1'
|
||||
variables['infinispan2lcSlot'] = 'for-orm-' + rootProject.ormVersion.family
|
||||
//Dependency on another Feature Pack:
|
||||
dependency "org.wildfly:wildfly-feature-pack:${project.wildflyVersion}" // It will assume it is "zip" by default
|
||||
//Ensure we declare all source repositories explicitly
|
||||
autoAddRepositories = false
|
||||
}
|
||||
|
||||
task createCoreFeaturePackZip( type: Zip, dependsOn: [featurepack] ) {
|
||||
baseName 'hibernate-orm-jbossmodules'
|
||||
from project.fpackStagingDir
|
||||
}
|
||||
|
||||
provision {
|
||||
dependsOn( createCoreFeaturePackZip )
|
||||
dependsOn( ":hibernate-envers:jar")
|
||||
dependsOn( ":hibernate-core:jar")
|
||||
configuration = file( 'wildfly-server-provisioning.xml' )
|
||||
destinationDir = file( "$project.wildFlyInstallDir" )
|
||||
//Override HCANN:
|
||||
override( 'org.hibernate.common:hibernate-commons-annotations' ) {
|
||||
version = project.hibernateCommonsVersion
|
||||
}
|
||||
variables['wildfly.version'] = project.wildflyVersion
|
||||
variables['hibernate-orm.version'] = rootProject.ormVersion.fullName
|
||||
//Ensure we declare all source repositories explicitly
|
||||
autoAddRepositories = false
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile project( ":hibernate-core" )
|
||||
testCompile project( ":hibernate-envers" )
|
||||
testCompile libraries.junit
|
||||
testCompile 'org.antlr:antlr4-runtime:4.7.1'
|
||||
|
||||
testCompile libraries.antlr
|
||||
testCompile libraries.arquillian_junit_container
|
||||
testCompile libraries.arquillian_protocol_servlet
|
||||
testCompile libraries.shrinkwrap_descriptors_api_javaee
|
||||
testCompile libraries.shrinkwrap_descriptors_impl_javaee
|
||||
testCompile libraries.wildfly_arquillian_container_managed
|
||||
|
||||
featurePack libraries.byteBuddy
|
||||
featurePack libraries.antlr4_runtime
|
||||
featurePack project( ":hibernate-core" )
|
||||
featurePack project( ":hibernate-envers" )
|
||||
featurePack "org.wildfly:jipijapa-hibernate5:${wildflyVersion}"
|
||||
featurePack "org.antlr:antlr4-runtime:4.7.1"
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
publishedArtifacts {
|
||||
artifact( createCoreFeaturePackZip ) {
|
||||
artifactId 'hibernate-orm-jbossmodules'
|
||||
description 'Main feature pack of Hibernate ORM: hibernate-core and hibernate-envers, including essential dependencies such as Byte Buddy'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task ciBuild( dependsOn: [clean, test, publish] )
|
||||
task release( dependsOn: [clean, test, bintrayUpload] )
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// tasks related to in-container (Arquillian + WF) testing
|
||||
|
||||
task prepareWildFlyForTests( dependsOn: [provision] ) {
|
||||
description = 'Downloads the WildFly distribution, installs it into a local directory, includes present version of Hibernate ORM, JPA 2.2 : ready for integration tests'
|
||||
}
|
||||
|
||||
test {
|
||||
exclude 'org/hibernate/wildfly/model/**'
|
||||
}
|
||||
|
||||
|
||||
test.dependsOn prepareWildFlyForTests
|
||||
//test.ignoreFailures = true
|
||||
|
||||
processTestResources {
|
||||
expand(
|
||||
[
|
||||
wildFlyInstallDir : project.wildFlyInstallDir,
|
||||
arquillianDeploymentExportDir: "${rootProject.buildDir.absolutePath}/arquillian-deployments"
|
||||
]
|
||||
)
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
-->
|
||||
<module xmlns="urn:jboss:module:1.3" name="net.bytebuddy" slot="${bytebuddySlot}">
|
||||
<properties>
|
||||
<property name="jboss.api" value="private"/>
|
||||
</properties>
|
||||
|
||||
<resources>
|
||||
<artifact name="${net.bytebuddy:byte-buddy}"/>
|
||||
</resources>
|
||||
<dependencies>
|
||||
<!-- ByteBuddy currently uses sun.misc.Unsafe -->
|
||||
<module name="sun.jdk"/>
|
||||
</dependencies>
|
||||
</module>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
-->
|
||||
<module-alias xmlns="urn:jboss:module:1.3"
|
||||
name="org.hibernate.orm" slot="${minorSlot}"
|
||||
target-name="org.hibernate.orm" target-slot="${slot}"
|
||||
/>
|
|
@ -1,21 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
-->
|
||||
<module xmlns="urn:jboss:module:1.3" name="org.hibernate" slot="${minorSlot}">
|
||||
|
||||
<properties>
|
||||
<property name="jboss.api" value="deprecated"/>
|
||||
<!-- This module is using the old name. Please use "org.hibernate.orm" in the future,
|
||||
and declare the dependency on "org.hibernate.envers" explicitly as well if it's used -->
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<module name="org.hibernate.orm" services="import" export="true" slot="${minorSlot}"/>
|
||||
<module name="org.hibernate.envers" services="import" export="true" slot="${minorSlot}"/>
|
||||
</dependencies>
|
||||
|
||||
</module>
|
|
@ -1,35 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
-->
|
||||
<module xmlns="urn:jboss:module:1.3" name="org.hibernate.orm" slot="${slot}">
|
||||
<resources>
|
||||
<artifact name="${org.hibernate.orm:hibernate-core}"/>
|
||||
</resources>
|
||||
|
||||
<dependencies>
|
||||
<module name="org.hibernate.envers" slot="${slot}" services="import" optional="true"/>
|
||||
<module name="com.fasterxml.classmate"/>
|
||||
<module name="javax.api"/>
|
||||
<module name="javax.annotation.api"/>
|
||||
<module name="javax.enterprise.api"/>
|
||||
<module name="javax.persistence.api"/>
|
||||
<module name="javax.transaction.api"/>
|
||||
<module name="javax.validation.api"/>
|
||||
<module name="javax.xml.bind.api"/>
|
||||
<module name="org.antlr.antlr4-runtime" slot="${antlrSlot}"/>
|
||||
<module name="org.dom4j"/>
|
||||
<module name="org.jboss.as.jpa.spi"/>
|
||||
<module name="org.jboss.jandex"/>
|
||||
<module name="org.jboss.logging"/>
|
||||
<module name="org.jboss.vfs"/>
|
||||
<module name="org.javassist" export="true" optional="true"/>
|
||||
<module name="org.hibernate.commons-annotations"/>
|
||||
<module name="org.hibernate.orm.jipijapa-hibernate5" services="import" slot="${slot}"/>
|
||||
<module name="net.bytebuddy" slot="${bytebuddySlot}" />
|
||||
<module name="org.infinispan.hibernate-cache" services="import" optional="true" slot="${infinispan2lcSlot}"/>
|
||||
</dependencies>
|
||||
</module>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
-->
|
||||
<module-alias xmlns="urn:jboss:module:1.3"
|
||||
name="org.hibernate.envers" slot="${minorSlot}"
|
||||
target-name="org.hibernate.envers" target-slot="${slot}"
|
||||
/>
|
|
@ -1,29 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
-->
|
||||
<module xmlns="urn:jboss:module:1.3" name="org.hibernate.envers" slot="${slot}">
|
||||
<resources>
|
||||
<artifact name="${org.hibernate.orm:hibernate-envers}"/>
|
||||
</resources>
|
||||
|
||||
<dependencies>
|
||||
<module name="org.hibernate.orm" slot="${slot}"/>
|
||||
<module name="com.fasterxml.classmate"/>
|
||||
<module name="javax.api"/>
|
||||
<module name="javax.annotation.api"/>
|
||||
<module name="javax.enterprise.api"/>
|
||||
<module name="javax.persistence.api"/>
|
||||
<module name="javax.transaction.api"/>
|
||||
<module name="javax.xml.bind.api"/>
|
||||
<module name="org.antlr"/>
|
||||
<module name="org.dom4j"/>
|
||||
<module name="org.jboss.jandex"/>
|
||||
<module name="org.jboss.logging"/>
|
||||
<module name="org.hibernate.commons-annotations"/>
|
||||
<module name="net.bytebuddy" slot="${bytebuddySlot}" />
|
||||
</dependencies>
|
||||
</module>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
-->
|
||||
<module-alias xmlns="urn:jboss:module:1.3"
|
||||
name="org.hibernate.orm.jipijapa-hibernate5" slot="${minorSlot}"
|
||||
target-name="org.hibernate.orm.jipijapa-hibernate5" target-slot="${slot}"
|
||||
/>
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
-->
|
||||
<module xmlns="urn:jboss:module:1.3" name="org.hibernate.orm.jipijapa-hibernate5" slot="${slot}">
|
||||
<properties>
|
||||
<property name="jboss.api" value="private"/>
|
||||
</properties>
|
||||
|
||||
<resources>
|
||||
<artifact name="${org.wildfly:jipijapa-hibernate5}"/>
|
||||
</resources>
|
||||
|
||||
<dependencies>
|
||||
<module name="org.hibernate.orm" slot="${slot}"/>
|
||||
<module name="javax.api"/>
|
||||
<module name="javax.annotation.api"/>
|
||||
<module name="javax.enterprise.api"/>
|
||||
<module name="javax.persistence.api"/>
|
||||
<module name="javax.transaction.api"/>
|
||||
<module name="javax.validation.api"/>
|
||||
<module name="javax.xml.bind.api"/>
|
||||
<module name="org.jboss.as.jpa.spi"/>
|
||||
<module name="org.jboss.jandex"/>
|
||||
<module name="org.jboss.logging"/>
|
||||
<module name="org.jboss.vfs"/>
|
||||
<module name="org.hibernate.commons-annotations"/>
|
||||
<module name="org.infinispan" services="import"/>
|
||||
<module name="org.infinispan.hibernate-cache" services="import" optional="true" slot="${infinispan2lcSlot}"/>
|
||||
</dependencies>
|
||||
</module>
|
|
@ -1,99 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.wildfly.integrationtest;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.envers.AuditReader;
|
||||
import org.hibernate.envers.AuditReaderFactory;
|
||||
import org.hibernate.wildfly.model.AuditedEntity;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
import org.jboss.shrinkwrap.descriptor.api.Descriptors;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceDescriptor;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceUnitTransactionType;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Chris Cranford
|
||||
*/
|
||||
// todo (6.0) : re-enable the test when envers is fixed
|
||||
|
||||
//@RunWith(Arquillian.class)
|
||||
public class HibernateEnversOnWildflyTest {
|
||||
|
||||
private static final String ORM_VERSION = Session.class.getPackage().getImplementationVersion();
|
||||
private static final String ORM_MINOR_VERSION = ORM_VERSION.substring( 0, ORM_VERSION.indexOf( ".", ORM_VERSION.indexOf( "." ) + 1 ) );
|
||||
|
||||
@Deployment
|
||||
public static WebArchive createDeployment() {
|
||||
return ShrinkWrap.create( WebArchive.class )
|
||||
.addClass( AuditedEntity.class )
|
||||
.addAsWebInfResource( EmptyAsset.INSTANCE, "beans.xml" )
|
||||
.addAsResource( new StringAsset( persistenceXml().exportAsString() ), "META-INF/persistence.xml" );
|
||||
}
|
||||
|
||||
private static PersistenceDescriptor persistenceXml() {
|
||||
return Descriptors.create( PersistenceDescriptor.class )
|
||||
.version( "2.1" )
|
||||
.createPersistenceUnit()
|
||||
.name( "primary" )
|
||||
.transactionType( PersistenceUnitTransactionType._JTA )
|
||||
.jtaDataSource( "java:jboss/datasources/ExampleDS" )
|
||||
.getOrCreateProperties()
|
||||
// We want to use the ORM from this build instead of the one coming with WildFly
|
||||
.createProperty().name( "jboss.as.jpa.providerModule" ).value( "org.hibernate:" + ORM_MINOR_VERSION ).up()
|
||||
.createProperty().name( "hibernate.hbm2ddl.auto" ).value( "create-drop" ).up()
|
||||
.createProperty().name( "hibernate.allow_update_outside_transaction" ).value( "true" ).up()
|
||||
.up().up();
|
||||
}
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Inject
|
||||
private UserTransaction userTransaction;
|
||||
|
||||
// @Test
|
||||
public void testEnversCompatibility() throws Exception {
|
||||
// revision 1
|
||||
userTransaction.begin();
|
||||
entityManager.joinTransaction();
|
||||
AuditedEntity entity = new AuditedEntity( 1, "Marco Polo" );
|
||||
entityManager.persist( entity );
|
||||
userTransaction.commit();
|
||||
|
||||
// revision 2
|
||||
userTransaction.begin();
|
||||
entityManager.joinTransaction();
|
||||
entity.setName( "George Washington" );
|
||||
entityManager.merge( entity );
|
||||
userTransaction.commit();
|
||||
|
||||
entityManager.clear();
|
||||
|
||||
// verify audit history revision counts
|
||||
userTransaction.begin();
|
||||
final AuditReader auditReader = AuditReaderFactory.get( entityManager );
|
||||
assertEquals( Arrays.asList( 1, 2 ), auditReader.getRevisions( AuditedEntity.class, 1 ) );
|
||||
userTransaction.commit();
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.wildfly.integrationtest;
|
||||
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.wildfly.model.Kryptonite;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
import org.jboss.shrinkwrap.descriptor.api.Descriptors;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceDescriptor;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceUnitTransactionType;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Integration test for using the current Hibernate ORM version on WildFly.
|
||||
* <p>
|
||||
* Gradle will unzip the targeted WildFly version and unpack the module ZIP created by this build into the server's
|
||||
* module directory. Arquillian is used to start this WildFly instance, run this test on the server and stop the server
|
||||
* again.
|
||||
*
|
||||
* @author Gunnar Morling
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
public class HibernateModulesOnWildflyTest {
|
||||
|
||||
private static final String ORM_VERSION = Session.class.getPackage().getImplementationVersion();
|
||||
private static final String ORM_MINOR_VERSION = ORM_VERSION.substring( 0, ORM_VERSION.indexOf( ".", ORM_VERSION.indexOf( "." ) + 1) );
|
||||
|
||||
@Deployment
|
||||
public static WebArchive createDeployment() {
|
||||
return ShrinkWrap.create( WebArchive.class )
|
||||
.addClass( Kryptonite.class )
|
||||
.addAsWebInfResource( EmptyAsset.INSTANCE, "beans.xml" )
|
||||
.addAsResource( new StringAsset( persistenceXml().exportAsString() ), "META-INF/persistence.xml" );
|
||||
}
|
||||
|
||||
private static PersistenceDescriptor persistenceXml() {
|
||||
return Descriptors.create( PersistenceDescriptor.class )
|
||||
.version( "2.1" )
|
||||
.createPersistenceUnit()
|
||||
.name( "primary" )
|
||||
.transactionType( PersistenceUnitTransactionType._JTA )
|
||||
.jtaDataSource( "java:jboss/datasources/ExampleDS" )
|
||||
.getOrCreateProperties()
|
||||
// We want to use the ORM from this build instead of the one coming with WildFly
|
||||
.createProperty().name( "jboss.as.jpa.providerModule" ).value( "org.hibernate:" + ORM_MINOR_VERSION ).up()
|
||||
.createProperty().name( "hibernate.hbm2ddl.auto" ).value( "create-drop" ).up()
|
||||
.createProperty().name( "hibernate.allow_update_outside_transaction" ).value( "true" ).up()
|
||||
.up().up();
|
||||
}
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Test
|
||||
public void shouldUseHibernateOrm52() {
|
||||
Session session = entityManager.unwrap( Session.class );
|
||||
|
||||
Kryptonite kryptonite1 = new Kryptonite();
|
||||
kryptonite1.id = 1L;
|
||||
kryptonite1.description = "Some Kryptonite";
|
||||
session.persist( kryptonite1 );
|
||||
|
||||
// EntityManager methods exposed through Session only as of 5.2
|
||||
Kryptonite loaded = session.find( Kryptonite.class, 1L );
|
||||
|
||||
assertThat( loaded.description, equalTo( "Some Kryptonite" ) );
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.wildfly.integrationtest;
|
||||
|
||||
import java.util.Properties;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl;
|
||||
import org.hibernate.bytecode.spi.BasicProxyFactory;
|
||||
import org.hibernate.bytecode.spi.BytecodeProvider;
|
||||
import org.hibernate.bytecode.spi.ProxyFactoryFactory;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.wildfly.model.Kryptonite;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.Asset;
|
||||
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
import org.jboss.shrinkwrap.descriptor.api.Descriptors;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceDescriptor;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceUnitTransactionType;
|
||||
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
import static org.hamcrest.core.IsNull.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* The purpose of this test is to check that it's still possible to use Javassist as byte code provider with WildFly.
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
public class JavassistHibernateModulesOnWildflyTest {
|
||||
|
||||
private static final String ORM_VERSION = Session.class.getPackage().getImplementationVersion();
|
||||
private static final String ORM_MINOR_VERSION = ORM_VERSION.substring( 0, ORM_VERSION.indexOf( ".", ORM_VERSION.indexOf( "." ) + 1) );
|
||||
|
||||
@Deployment
|
||||
public static WebArchive createDeployment() {
|
||||
return ShrinkWrap.create( WebArchive.class )
|
||||
.addClass( Kryptonite.class )
|
||||
.addAsWebInfResource( EmptyAsset.INSTANCE, "beans.xml" )
|
||||
.addAsResource( persistenceXml(), "META-INF/persistence.xml" );
|
||||
}
|
||||
|
||||
private static Asset persistenceXml() {
|
||||
PersistenceDescriptor persistenceXml = Descriptors.create( PersistenceDescriptor.class )
|
||||
.version( "2.1" )
|
||||
.createPersistenceUnit()
|
||||
.name( "primary" )
|
||||
.transactionType( PersistenceUnitTransactionType._JTA )
|
||||
.jtaDataSource( "java:jboss/datasources/ExampleDS" )
|
||||
.getOrCreateProperties()
|
||||
// We want to use the ORM from this build instead of the one coming with WildFly
|
||||
.createProperty().name( "jboss.as.jpa.providerModule" ).value( "org.hibernate:" + ORM_MINOR_VERSION ).up()
|
||||
.createProperty().name( "hibernate.hbm2ddl.auto" ).value( "create-drop" ).up()
|
||||
.createProperty().name( "hibernate.allow_update_outside_transaction" ).value( "true" ).up()
|
||||
.up().up();
|
||||
return new StringAsset( persistenceXml.exportAsString() );
|
||||
}
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Test
|
||||
public void shouldUseHibernateOrm52() {
|
||||
Session session = entityManager.unwrap( Session.class );
|
||||
|
||||
Kryptonite kryptonite1 = new Kryptonite();
|
||||
kryptonite1.id = 1L;
|
||||
kryptonite1.description = "Some Kryptonite";
|
||||
session.persist( kryptonite1 );
|
||||
|
||||
// EntityManager methods exposed through Session only as of 5.2
|
||||
Kryptonite loaded = session.find( Kryptonite.class, 1L );
|
||||
|
||||
assertThat( loaded.description, equalTo( "Some Kryptonite" ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldBeAbleToCreateProxyWithJavassist() {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty( AvailableSettings.BYTECODE_PROVIDER, Environment.BYTECODE_PROVIDER_NAME_JAVASSIST );
|
||||
|
||||
// hibernate.bytecode.provider is a system property. I don't want to apply it
|
||||
// to the arquillian.xml because it will change the other tests as well.
|
||||
// I guess this is a more explicit way anyway to test that Javassist is available.
|
||||
BytecodeProvider provider = Environment.buildBytecodeProvider( properties );
|
||||
assertThat( provider.getClass(), equalTo( BytecodeProviderImpl.class ) );
|
||||
|
||||
ProxyFactoryFactory factory = provider.getProxyFactoryFactory();
|
||||
BasicProxyFactory basicProxyFactory = factory.buildBasicProxyFactory( Kryptonite.class, null );
|
||||
Object proxy = basicProxyFactory.getProxy();
|
||||
assertThat( proxy, notNullValue() );
|
||||
}
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.wildfly.integrationtest;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityTransaction;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.engine.transaction.spi.TransactionImplementor;
|
||||
import org.hibernate.wildfly.model.Kryptonite;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
|
||||
import org.jboss.shrinkwrap.api.asset.StringAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
import org.jboss.shrinkwrap.descriptor.api.Descriptors;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceDescriptor;
|
||||
import org.jboss.shrinkwrap.descriptor.api.persistence21.PersistenceUnitTransactionType;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
@RunWith(Arquillian.class)
|
||||
public class TransactionRollbackTest {
|
||||
|
||||
private static final String ORM_VERSION = Session.class.getPackage().getImplementationVersion();
|
||||
private static final String ORM_MINOR_VERSION = ORM_VERSION.substring( 0,
|
||||
ORM_VERSION.indexOf(
|
||||
".",
|
||||
ORM_VERSION.indexOf( "." ) + 1
|
||||
)
|
||||
);
|
||||
|
||||
@Deployment
|
||||
public static WebArchive createDeployment() {
|
||||
return ShrinkWrap.create( WebArchive.class )
|
||||
.addClass( Kryptonite.class )
|
||||
.addAsWebInfResource( EmptyAsset.INSTANCE, "beans.xml" )
|
||||
.addAsResource( new StringAsset( persistenceXml().exportAsString() ), "META-INF/persistence.xml" );
|
||||
}
|
||||
|
||||
private static PersistenceDescriptor persistenceXml() {
|
||||
return Descriptors.create( PersistenceDescriptor.class )
|
||||
.version( "2.1" )
|
||||
.createPersistenceUnit()
|
||||
.name( "primary" )
|
||||
.transactionType( PersistenceUnitTransactionType._RESOURCE_LOCAL )
|
||||
.jtaDataSource( "java:jboss/datasources/ExampleDS" )
|
||||
.getOrCreateProperties()
|
||||
// We want to use the ORM from this build instead of the one coming with WildFly
|
||||
.createProperty()
|
||||
.name( "jboss.as.jpa.providerModule" )
|
||||
.value( "org.hibernate:" + ORM_MINOR_VERSION )
|
||||
.up()
|
||||
.createProperty()
|
||||
.name( "hibernate.hbm2ddl.auto" )
|
||||
.value( "create-drop" )
|
||||
.up()
|
||||
.createProperty()
|
||||
.name( "hibernate.allow_update_outside_transaction" )
|
||||
.value( "true" )
|
||||
.up()
|
||||
.up()
|
||||
.up();
|
||||
}
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Test
|
||||
public void testMarkRollbackOnlyAnUnactiveTransaction() {
|
||||
EntityTransaction transaction = entityManager.getTransaction();
|
||||
final TransactionImplementor hibernateTransaction = (TransactionImplementor) transaction;
|
||||
hibernateTransaction.markRollbackOnly();
|
||||
transaction.rollback();
|
||||
assertFalse( transaction.isActive() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarkRollbackOnlyAnActiveTransaction() {
|
||||
EntityTransaction transaction = entityManager.getTransaction();
|
||||
final TransactionImplementor hibernateTransaction = (TransactionImplementor) transaction;
|
||||
transaction.begin();
|
||||
hibernateTransaction.markRollbackOnly();
|
||||
transaction.rollback();
|
||||
assertFalse( transaction.isActive() );
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.wildfly.model;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
|
||||
/**
|
||||
* @author Chris Cranford
|
||||
*/
|
||||
@Audited
|
||||
@Entity
|
||||
public class AuditedEntity {
|
||||
@Id
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
AuditedEntity() {
|
||||
|
||||
}
|
||||
|
||||
public AuditedEntity(Integer id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if ( this == object ) {
|
||||
return true;
|
||||
}
|
||||
if ( object == null || !( object instanceof AuditedEntity ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AuditedEntity that = (AuditedEntity) object;
|
||||
return !( name != null ? !name.equals( that.name ) : that.name != null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ( name != null ? name.hashCode() : 0 );
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.wildfly.model;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
* @author Gunnar Morling
|
||||
*/
|
||||
@Entity
|
||||
public class Kryptonite {
|
||||
|
||||
@Id
|
||||
public long id;
|
||||
|
||||
public String description;
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
-->
|
||||
<arquillian
|
||||
xmlns="http://jboss.org/schema/arquillian"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
|
||||
|
||||
<defaultProtocol type="Servlet 3.0" />
|
||||
|
||||
<!-- Uncomment in order to inspect deployments -->
|
||||
<!--
|
||||
<engine>
|
||||
<property name="deploymentExportPath">${arquillianDeploymentExportDir}</property>
|
||||
</engine>
|
||||
-->
|
||||
|
||||
<group qualifier="Grid" default="true">
|
||||
<container qualifier="container.active-1" mode="suite" default="true">
|
||||
<configuration>
|
||||
<property name="jbossHome">${wildFlyInstallDir}</property>
|
||||
<!-- For Remote debugging of Wildfly add the following line to the 'javaVmArguments' section below: -->
|
||||
<!-- -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y-->
|
||||
<!-- DO NOT add comments within the property section below as the Arquillian parser can't deal with it -->
|
||||
<property name="javaVmArguments">
|
||||
-Dee8.preview.mode=true
|
||||
-Djava.net.preferIPv4Stack=true
|
||||
-Djgroups.bind_addr=127.0.0.1
|
||||
</property>
|
||||
</configuration>
|
||||
</container>
|
||||
</group>
|
||||
</arquillian>
|
|
@ -1,15 +0,0 @@
|
|||
<!-- Use of copy-module-artifacts is essential to make sure we use the current
|
||||
builds rather than whatever stale snapshot one might have in local Maven
|
||||
repositories: JBoss Modules would otherwise load jars from the local Maven -->
|
||||
<server-provisioning xmlns="urn:wildfly:server-provisioning:1.1" copy-module-artifacts="true">
|
||||
<feature-packs>
|
||||
<feature-pack
|
||||
groupId="org.hibernate.orm"
|
||||
artifactId="hibernate-orm-jbossmodules"
|
||||
version="${hibernate-orm.version}" />
|
||||
<feature-pack
|
||||
groupId="org.wildfly"
|
||||
artifactId="wildfly-feature-pack"
|
||||
version="${wildfly.version}" />
|
||||
</feature-packs>
|
||||
</server-provisioning>
|
|
@ -64,7 +64,6 @@ include 'hibernate-ehcache'
|
|||
include 'hibernate-infinispan'
|
||||
include 'hibernate-jipijapa'
|
||||
|
||||
include 'hibernate-orm-modules'
|
||||
include 'hibernate-graalvm'
|
||||
|
||||
if ( JavaVersion.current().isJava11Compatible() ) {
|
||||
|
|
Loading…
Reference in New Issue