Skip to content

Commit 05677eb

Browse files
committed
HHH-19107 fix @EmbeddedId with CrudRepository
1 parent b3c10d6 commit 05677eb

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* SPDX-License-Identifier: LGPL-2.1-or-later
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.processor.test.data.embeddedid;
6+
7+
import org.hibernate.processor.test.util.CompilationTest;
8+
import org.hibernate.processor.test.util.WithClasses;
9+
import org.junit.Test;
10+
11+
import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
12+
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;
13+
14+
/**
15+
* @author Gavin King
16+
*/
17+
public class EmbeddedIdTest extends CompilationTest {
18+
@Test
19+
@WithClasses({ Thing.class, ThingRepo.class })
20+
public void test() {
21+
System.out.println( getMetaModelSourceAsString( ThingRepo.class ) );
22+
assertMetamodelClassGeneratedFor( Thing.class, true );
23+
assertMetamodelClassGeneratedFor( Thing.class );
24+
assertMetamodelClassGeneratedFor( ThingRepo.class );
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* SPDX-License-Identifier: LGPL-2.1-or-later
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.processor.test.data.embeddedid;
6+
7+
import jakarta.persistence.Embeddable;
8+
import jakarta.persistence.EmbeddedId;
9+
import jakarta.persistence.Entity;
10+
11+
@Entity
12+
public class Thing {
13+
@Embeddable
14+
public static class Id {
15+
long id;
16+
String key;
17+
}
18+
19+
@EmbeddedId Id id;
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* SPDX-License-Identifier: LGPL-2.1-or-later
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.processor.test.data.embeddedid;
6+
7+
import jakarta.data.repository.CrudRepository;
8+
import jakarta.data.repository.Find;
9+
import jakarta.data.repository.Repository;
10+
11+
@Repository
12+
public interface ThingRepo extends CrudRepository<Thing, Thing.Id> {
13+
@Find
14+
Thing thing(Thing.Id id);
15+
}

tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2226,7 +2226,7 @@ private static TypeMirror memberType(Element member) {
22262226
final AccessType accessType = getAccessType(entityType);
22272227
final String nextToken = tokens.nextToken();
22282228
for ( Element member : context.getAllMembers(entityType) ) {
2229-
if ( isIdRef(nextToken) && hasAnnotation( member, ID) ) {
2229+
if ( isIdRef(nextToken) && hasAnnotation(member, ID, EMBEDDED_ID) ) {
22302230
return member;
22312231
}
22322232
final Element match =

0 commit comments

Comments
 (0)