Skip to content

Commit 022aaa6

Browse files
lpandzicclaude
andcommitted
fix: use Embeddeds.isEmbedded to detect all @Embedded variants in element collection
The embedded entity collection only checked for @Embedded, missing @Embedded.Empty and @Embedded.Nullable. This caused those fields to be generated as SimplePath instead of being flattened. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 6df244b commit 022aaa6

3 files changed

Lines changed: 3 additions & 6 deletions

File tree

infobip-spring-data-jdbc-annotation-processor-common/src/main/java/com/infobip/spring/data/jdbc/annotation/processor/SpringDataJdbcAnnotationProcessorBase.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import javax.lang.model.element.TypeElement;
66
import javax.lang.model.util.ElementFilter;
77
import java.lang.annotation.Annotation;
8-
import java.util.Objects;
98
import java.util.Optional;
109
import java.util.Set;
1110
import java.util.function.Function;
@@ -142,9 +141,7 @@ private Stream<TypeElement> getEntityElementWithEmbeddedEntities(TypeElement ent
142141
var types = processingEnv.getTypeUtils();
143142
var embeddedElements = ElementFilter.fieldsIn(entityElement.getEnclosedElements())
144143
.stream()
145-
.filter(enclosedElement -> Objects.nonNull(
146-
enclosedElement.getAnnotation(
147-
conf.getEmbeddedAnnotation())))
144+
.filter(enclosedElement -> Embeddeds.isEmbedded(conf, enclosedElement))
148145
.map(element -> types.asElement(element.asType()))
149146
.filter(element -> element instanceof TypeElement)
150147
.map(element -> (TypeElement) element)

infobip-spring-data-jdbc-annotation-processor/src/test/resources/expected/QEntityWithEmbeddedEmpty.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
@Generated("com.infobip.spring.data.jdbc.annotation.processor.CustomMetaDataSerializer")
2121
public class QEntityWithEmbeddedEmpty extends com.querydsl.sql.RelationalPathBase<EntityWithEmbeddedEmpty> {
2222

23-
private static final long serialVersionUID = -229043138;
23+
private static final long serialVersionUID = 738162607;
2424

2525
public static final QEntityWithEmbeddedEmpty entityWithEmbeddedEmpty = new QEntityWithEmbeddedEmpty("EntityWithEmbeddedEmpty");
2626

infobip-spring-data-jdbc-annotation-processor/src/test/resources/expected/QEntityWithEmbeddedNullable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
@Generated("com.infobip.spring.data.jdbc.annotation.processor.CustomMetaDataSerializer")
2121
public class QEntityWithEmbeddedNullable extends com.querydsl.sql.RelationalPathBase<EntityWithEmbeddedNullable> {
2222

23-
private static final long serialVersionUID = -229043138;
23+
private static final long serialVersionUID = 1557633471;
2424

2525
public static final QEntityWithEmbeddedNullable entityWithEmbeddedNullable = new QEntityWithEmbeddedNullable("EntityWithEmbeddedNullable");
2626

0 commit comments

Comments
 (0)