From 46f3a104561cb8b6e0d10123b0116deb7d026e76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Westk=C3=A4mper?= Date: Tue, 26 Aug 2014 21:47:39 +0300 Subject: [PATCH] Fix projection handling for embeddable types --- .../mysema/query/apt/GenericExporterTest.java | 2 + .../mysema/query/domain/Embeddable3Test.java | 37 +++++++++++++++++++ .../query/codegen/EmbeddableSerializer.java | 23 ++---------- 3 files changed, 43 insertions(+), 19 deletions(-) create mode 100644 querydsl-apt/src/test/java/com/mysema/query/domain/Embeddable3Test.java diff --git a/querydsl-apt/src/test/java/com/mysema/query/apt/GenericExporterTest.java b/querydsl-apt/src/test/java/com/mysema/query/apt/GenericExporterTest.java index d5e1f8a64..2c3e91c86 100644 --- a/querydsl-apt/src/test/java/com/mysema/query/apt/GenericExporterTest.java +++ b/querydsl-apt/src/test/java/com/mysema/query/apt/GenericExporterTest.java @@ -44,6 +44,7 @@ public class GenericExporterTest extends AbstractProcessorTest { expected.add("QQueryProjectionTest_DTOWithProjection.java"); expected.add("QQueryProjectionTest_EntityWithProjection.java"); + expected.add("QEmbeddable3Test_EmbeddableClass.java"); // FIXME expected.add("QExternalEntityTest_MyEntity.java"); @@ -82,6 +83,7 @@ public class GenericExporterTest extends AbstractProcessorTest { expected.add("QTemporal2Test_Cheque.java"); expected.add("QQueryProjectionTest_DTOWithProjection.java"); expected.add("QQueryProjectionTest_EntityWithProjection.java"); + expected.add("QEmbeddable3Test_EmbeddableClass.java"); // FIXME expected.add("QGeneric4Test_HidaBez.java"); diff --git a/querydsl-apt/src/test/java/com/mysema/query/domain/Embeddable3Test.java b/querydsl-apt/src/test/java/com/mysema/query/domain/Embeddable3Test.java new file mode 100644 index 000000000..6204f2600 --- /dev/null +++ b/querydsl-apt/src/test/java/com/mysema/query/domain/Embeddable3Test.java @@ -0,0 +1,37 @@ +package com.mysema.query.domain; + +import com.mysema.query.annotations.QueryEmbeddable; +import com.mysema.query.annotations.QueryProjection; +import com.mysema.query.support.Expressions; +import org.junit.Test; + +public class Embeddable3Test { + + @QueryEmbeddable + public static class EmbeddableClass { + private Integer embeddedProperty; + + public EmbeddableClass() { } + + @QueryProjection + public EmbeddableClass(Integer embeddedProperty) { + super(); + this.embeddedProperty = embeddedProperty; + } + + public Integer getEmbeddedProperty() { + return embeddedProperty; + } + + public void setEmbeddedProperty(Integer embeddedProperty) { + this.embeddedProperty = embeddedProperty; + } + + } + + @Test + public void test() { + QEmbeddable3Test_EmbeddableClass.create(Expressions.path(Integer.class, "num")); + } + +} diff --git a/querydsl-codegen/src/main/java/com/mysema/query/codegen/EmbeddableSerializer.java b/querydsl-codegen/src/main/java/com/mysema/query/codegen/EmbeddableSerializer.java index daf236154..aca0ac336 100644 --- a/querydsl-codegen/src/main/java/com/mysema/query/codegen/EmbeddableSerializer.java +++ b/querydsl-codegen/src/main/java/com/mysema/query/codegen/EmbeddableSerializer.java @@ -13,30 +13,20 @@ */ package com.mysema.query.codegen; -import static com.mysema.codegen.Symbols.UNCHECKED; - +import javax.inject.Inject; +import javax.inject.Named; import java.io.IOException; import java.lang.annotation.Annotation; import java.util.Collection; -import javax.inject.Inject; -import javax.inject.Named; - import com.mysema.codegen.CodeWriter; import com.mysema.codegen.model.ClassType; import com.mysema.codegen.model.Type; import com.mysema.codegen.model.TypeCategory; import com.mysema.codegen.model.Types; import com.mysema.query.types.Path; -import com.mysema.query.types.path.BeanPath; -import com.mysema.query.types.path.BooleanPath; -import com.mysema.query.types.path.ComparablePath; -import com.mysema.query.types.path.DatePath; -import com.mysema.query.types.path.DateTimePath; -import com.mysema.query.types.path.EnumPath; -import com.mysema.query.types.path.NumberPath; -import com.mysema.query.types.path.StringPath; -import com.mysema.query.types.path.TimePath; +import com.mysema.query.types.path.*; +import static com.mysema.codegen.Symbols.UNCHECKED; /** * EmbeddableSerializer is a {@link Serializer} implementation for embeddable types @@ -96,9 +86,4 @@ public final class EmbeddableSerializer extends EntitySerializer { writer.privateStaticFinal(Types.LONG_P, "serialVersionUID", model.hashCode() + "L"); } - @Override - protected void introFactoryMethods(CodeWriter writer, EntityType model) throws IOException { - // no factory methods - } - }