50 lines
2 KiB
Text
50 lines
2 KiB
Text
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Employee
|
|
http://java-persistence-performance.blogspot.com/2013/06/cool-performance-features-of.html
|
|
|
|
pkill -9 crdb && rm -rf /tmp/far/* && (cd /tmp/far; crdb start --background --http-port=9090 --vmodule=executor=2; sleep 1) && echo "create database farsite;" | crdb sql && tail -f /tmp/far/cockroach-data/logs/crdb.log
|
|
|
|
|
|
// jpa weaving
|
|
def entitiesBasePackage = 'com.example.farsite.model'
|
|
|
|
compileJava {
|
|
destinationDir file("$buildDir/compiled-classes")
|
|
}
|
|
|
|
task copyNonPersistentClasses(type: Copy, dependsOn: compileJava) {
|
|
from "$buildDir/compiled-classes"
|
|
into sourceSets.main.output.classesDir
|
|
exclude '**/' + entitiesBasePackage.replaceAll('\\.','/') + '/**'
|
|
includeEmptyDirs = false
|
|
}
|
|
task copyPersistentClasses(type: Copy, dependsOn: compileJava) {
|
|
from "$buildDir/compiled-classes"
|
|
into "$buildDir/unwoven-persistent-classes"
|
|
include '**/' + entitiesBasePackage.replaceAll('\\.','/') + '/**'
|
|
includeEmptyDirs = false
|
|
}
|
|
task weaveJpaEntities(type: JavaExec, dependsOn: [copyPersistentClasses,processResources]) {
|
|
main = 'org.eclipse.persistence.tools.weaving.jpa.StaticWeave'
|
|
classpath configurations.weave.incoming.files
|
|
args '-persistenceinfo'
|
|
args processResources.destinationDir.absolutePath
|
|
args '-classpath'
|
|
args configurations.compile.incoming.files.asPath
|
|
args '-loglevel'
|
|
args 'INFO'
|
|
args copyPersistentClasses.destinationDir.absolutePath
|
|
args sourceSets.main.output.classesDir.absolutePath
|
|
|
|
inputs.files fileTree(copyPersistentClasses.destinationDir),fileTree(processResources.destinationDir).matching({pattern -> pattern.include('**/META-INF/persistence.xml')})
|
|
outputs.dir sourceSets.main.output.classesDir
|
|
}
|
|
//classes.dependsOn copyNonPersistentClasses,weaveJpaEntities
|
|
|
|
dependencies
|
|
weave group: 'org.eclipse.persistence', name: 'javax.persistence', version: '2.+'
|
|
weave group: 'org.eclipse.persistence', name: 'org.eclipse.persistence.jpa', version: '2.+'
|
|
|
|
configurations
|
|
weave
|
|
|
|
mainClassName = "com.example.farsite.Main"
|