Skip to content

Commit

Permalink
Better support for QuerySupertype #565
Browse files Browse the repository at this point in the history
  • Loading branch information
timowest committed Nov 20, 2013
1 parent d2b6ee4 commit 0660b86
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 15 deletions.
@@ -1,6 +1,6 @@
/*
* Copyright 2011, Mysema Ltd
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -23,15 +23,16 @@
import javax.persistence.Embedded;

import com.mysema.query.annotations.QueryEntities;
import com.mysema.query.annotations.QuerySupertype;
import com.mysema.query.apt.AbstractQuerydslProcessor;
import com.mysema.query.apt.Configuration;
import com.mysema.query.apt.DefaultConfiguration;
import com.mysema.query.codegen.Keywords;

/**
* AnnotationProcessor for JDO which takes {@link PersistenceCapable}, {@link EmbeddedOnly} and
* AnnotationProcessor for JDO which takes {@link PersistenceCapable}, {@link EmbeddedOnly} and
* {@link NotPersistent} into account
*
*
* @author tiwe
*
*/
Expand All @@ -40,11 +41,13 @@ public class JDOAnnotationProcessor extends AbstractQuerydslProcessor {

@Override
protected Configuration createConfiguration(RoundEnvironment roundEnv) {
Class<? extends Annotation> entities = QueryEntities.class;
Class<? extends Annotation> entity = PersistenceCapable.class;
Class<? extends Annotation> superType = QuerySupertype.class;
Class<? extends Annotation> embeddable = EmbeddedOnly.class;
Class<? extends Annotation> embedded = Embedded.class;
Class<? extends Annotation> skip = NotPersistent.class;
return new DefaultConfiguration(roundEnv, processingEnv.getOptions(), Keywords.JDO,
QueryEntities.class, entity, null, embeddable, embedded, skip);
return new DefaultConfiguration(roundEnv, processingEnv.getOptions(), Keywords.JDO,
entities, entity, superType, embeddable, embedded, skip);
}
}
@@ -1,6 +1,6 @@
/*
* Copyright 2011, Mysema Ltd
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -27,24 +27,24 @@
import com.mysema.query.apt.Configuration;

/**
* AnnotationProcessor for JPA which takes {@link Entity}, {@link MappedSuperclass}, {@link Embeddable}
* AnnotationProcessor for JPA which takes {@link Entity}, {@link MappedSuperclass}, {@link Embeddable}
* and {@link Transient} into account
*
*
* @author tiwe
*
*/
@SupportedAnnotationTypes({"com.mysema.query.annotations.*","javax.persistence.*"})
public class JPAAnnotationProcessor extends AbstractQuerydslProcessor {

@Override
protected Configuration createConfiguration(RoundEnvironment roundEnv) {
Class<? extends Annotation> entity = Entity.class;
Class<? extends Annotation> superType = MappedSuperclass.class;
Class<? extends Annotation> embeddable = Embeddable.class;
Class<? extends Annotation> embedded = Embedded.class;
Class<? extends Annotation> skip = Transient.class;
return new JPAConfiguration(roundEnv, processingEnv.getOptions(), entity, superType,
embeddable, embedded, skip);
return new JPAConfiguration(roundEnv, processingEnv.getOptions(),
entity, superType, embeddable, embedded, skip);
}

}
Expand Up @@ -24,6 +24,7 @@
import org.mongodb.morphia.annotations.Transient;

import com.mysema.query.annotations.QueryEntities;
import com.mysema.query.annotations.QuerySupertype;
import com.mysema.query.apt.AbstractQuerydslProcessor;
import com.mysema.query.apt.Configuration;
import com.mysema.query.apt.DefaultConfiguration;
Expand All @@ -41,10 +42,12 @@ public class MorphiaAnnotationProcessor extends AbstractQuerydslProcessor {
protected Configuration createConfiguration(RoundEnvironment roundEnv) {
Class<? extends Annotation> entities = QueryEntities.class;
Class<? extends Annotation> entity = Entity.class;
Class<? extends Annotation> superType = QuerySupertype.class;
Class<? extends Annotation> embedded = Embedded.class;
Class<? extends Annotation> skip = Transient.class;
DefaultConfiguration conf = new DefaultConfiguration(roundEnv, processingEnv.getOptions(), Collections.<String>emptySet(),
entities, entity, null, null, embedded, skip);
DefaultConfiguration conf = new DefaultConfiguration(roundEnv,
processingEnv.getOptions(), Collections.<String>emptySet(),
entities, entity, superType, null, embedded, skip);
try {
Class cl = Class.forName("com.mysema.query.mongodb.Point");
conf.addCustomType(Double[].class, cl);
Expand Down
Expand Up @@ -47,8 +47,8 @@ protected Configuration createConfiguration(RoundEnvironment roundEnv) {
Class<? extends Annotation> embeddable = Embeddable.class;
Class<? extends Annotation> embedded = Embedded.class;
Class<? extends Annotation> skip = Transient.class;
DefaultConfiguration conf = new JPAConfiguration(roundEnv, processingEnv.getOptions(), entity, superType,
embeddable, embedded, skip);
DefaultConfiguration conf = new JPAConfiguration(roundEnv, processingEnv.getOptions(),
entity, superType, embeddable, embedded, skip);
conf.setAlternativeEntityAnnotation(RooJpaActiveRecord.class);
return conf;
}
Expand Down
@@ -0,0 +1,31 @@
package com.mysema.query.domain;

import static org.junit.Assert.assertEquals;

import java.util.Set;

import javax.jdo.annotations.PersistenceCapable;

import org.junit.Test;

import com.mysema.query.annotations.QuerySupertype;

public class QuerySuperTypeTest {

@QuerySupertype
public static class Supertype {

}

@PersistenceCapable
public static class JdoEntity {
Set<Supertype> references;
}

@Test
public void JdoEntity() {
assertEquals(QQuerySuperTypeTest_Supertype.class,
QQuerySuperTypeTest_JdoEntity.jdoEntity.references.any().getClass());
}

}

0 comments on commit 0660b86

Please sign in to comment.