Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HHH-19107 fix @EmbeddedId with CrudRepository #9706

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.processor.test.data.embeddedid;

import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;

/**
* @author Gavin King
*/
public class EmbeddedIdTest extends CompilationTest {
@Test
@WithClasses({ Thing.class, ThingRepo.class })
public void test() {
System.out.println( getMetaModelSourceAsString( ThingRepo.class ) );
assertMetamodelClassGeneratedFor( Thing.class, true );
assertMetamodelClassGeneratedFor( Thing.class );
assertMetamodelClassGeneratedFor( ThingRepo.class );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.processor.test.data.embeddedid;

import jakarta.persistence.Embeddable;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;

@Entity
public class Thing {
@Embeddable
public static class Id {
long id;
String key;
}

@EmbeddedId Id id;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.processor.test.data.embeddedid;

import jakarta.data.repository.CrudRepository;
import jakarta.data.repository.Find;
import jakarta.data.repository.Repository;

@Repository
public interface ThingRepo extends CrudRepository<Thing, Thing.Id> {
@Find
Thing thing(Thing.Id id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2226,7 +2226,7 @@ private static TypeMirror memberType(Element member) {
final AccessType accessType = getAccessType(entityType);
final String nextToken = tokens.nextToken();
for ( Element member : context.getAllMembers(entityType) ) {
if ( isIdRef(nextToken) && hasAnnotation( member, ID) ) {
if ( isIdRef(nextToken) && hasAnnotation(member, ID, EMBEDDED_ID) ) {
return member;
}
final Element match =
Expand Down
Loading