Static Metamodel Generator

To generate static metamodel classes for managed types (Entity, MappedSuperclass and Embeddable), add cmobilecom-jpa-processor.jar in compile classpath.

For example, gradle build: generate static metamodel sources for the main source set that contains JPA managed types.


dependencies {
	// annotation processor: generate static metamodel
	compileOnly 'com.cmobilecom:cmobilecom-jpa-processor:1.1.1'

// source: include generated static metamodel classes
def generatedSourceDir = "${project.buildDir}/generated/java"
sourceSets {
	test {
		java {
			srcDirs generatedSourceDir

compileJava {
	options.compilerArgs << "-s"
	options.compilerArgs << generatedSourceDir

	doFirst {
		// create output directory if it does not exists
		File dir = new File(generatedSourceDir);
		if (!dir.exists())
		else {
			// workaround for JDK 8 bug: java.lang.IllegalStateException: endPosTable already set
			FileCollection generatedFiles = files { file(generatedSourceDir).listFiles() }
			generatedFiles.each { delete it }


dependencies {
	// annotation processor: generate static metamodel
	// Android does not have javax.annotation that is requried to compile generated sources
	// but it is not needed runtime.
	compileOnly group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
	annotationProcessor 'com.cmobilecom:cmobilecom-jpa-processor:1.1.1'
The generated metamodel classes have the same package names, and they can be used in your JPA source code. For example,
	Root<Employer> root = criteriaQuery.from(Employer.class);
	ListJoin<Employer, Employee> employees = root.join(Employer_.employees);
	Path<String> employeeName = employees.get(;