-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Preliminary support for Panache2 #10411
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
base: main
Are you sure you want to change the base?
Conversation
- Detect Panache2 in classpath - Detect Panache2 types for entities and repositories
Since repositories can be nested in entities, we can use the outer type
Comes with 4 out of the box: - managed/blocking (generated) - managed/reactive (generated if reactive-common is in the CP) - stateless/blocking (generated) - stateless/reactive (generated if reactive-common is in the CP) - whatever nested repositories from the entity -- and if they implement one of the first four, we use this instead of the generated one
… Uni to decide for reactive session
Thanks for your pull request! This pull request does not follow the contribution rules. Could you have a look? ❌ All commit messages should start with a JIRA issue key matching pattern › This message was automatically generated. |
tooling/metamodel-generator/src/main/java/org/hibernate/processor/util/TypeUtils.java
Outdated
Show resolved
Hide resolved
@@ -373,7 +382,7 @@ private void processClasses(RoundEnvironment roundEnvironment) { | |||
try { | |||
final AnnotationMetaEntity metaEntity = | |||
AnnotationMetaEntity.create( typeElement, context, | |||
parentMetadata( typeElement, context::getMetaEntity ) ); | |||
parentMetadata( typeElement, context::getMetaEntity ), null ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about overloading AnnotationMetaEntity.create()
instead of passing null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was waiting for Java to get defaulted params.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good plan.
switch(typedIdMember.getKind()) { | ||
case ARRAY: | ||
case DECLARED: | ||
case BOOLEAN: | ||
case BYTE: | ||
case CHAR: | ||
case SHORT: | ||
case INT: | ||
case LONG: | ||
case FLOAT: | ||
case DOUBLE: | ||
return typedIdMember; | ||
case EXECUTABLE: | ||
return ((ExecutableType) typedIdMember).getReturnType(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch
expression?
private @Nullable Element findIdMember() { | ||
if ( primaryEntity == null ) { | ||
message( element, | ||
"No primary entity defined to find id member", | ||
Diagnostic.Kind.ERROR ); | ||
return null; | ||
} | ||
for ( Element member : context.getAllMembers( primaryEntity ) ) { | ||
if ( hasAnnotation( member, ID, EMBEDDED_ID ) ) { | ||
return member; | ||
} | ||
} | ||
message( element, | ||
"Could not find any member annotated with @Id or @EmbeddedId", | ||
Diagnostic.Kind.ERROR ); | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you also look for an @IdClass
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should definitely.
Is this code example missing a |
@@ -253,9 +253,16 @@ private boolean handleSettings(ProcessingEnvironment environment) { | |||
PackageElement quarkusOrmPanachePackage = | |||
context.getProcessingEnvironment().getElementUtils() | |||
.getPackageElement( "io.quarkus.hibernate.orm.panache" ); | |||
PackageElement quarkusPanache2Package = | |||
context.getProcessingEnvironment().getElementUtils() | |||
.getPackageElement( "io.quarkus.hibernate.panache" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed at some point going with "Quarkus Data" instead of "Panache 2"... Are you sure you still want to go with this name and package? io.quarkus.data.hibernate
could work too, in that case?
Maybe this is a discussion we should take offline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we? Or are you just trying to trick me because you know my memory doesn't go that far? 🤔
Well no, this is with the ORM |
Ah OK, I see. |
@FroMage the bot is nagging you about your |
@FroMage the bot is also nagging you about not removing the dual-licensing notice in the PR description ;) |
…sor/util/TypeUtils.java Co-authored-by: Gavin King <gavin@hibernate.org>
TypeElement primaryEntityForTest = primaryEntity; | ||
if ( idMember != null && primaryEntityForTest != null ) { | ||
TypeMirror typedIdMember = this.context.getTypeUtils().asMemberOf((DeclaredType) primaryEntityForTest.asType(), idMember); | ||
TypeMirror idType = null; |
Check notice
Code scanning / CodeQL
Unread local variable Note
Supports Panache2, which comes in a new package
io.quarkus.hibernate.panache
(since it supports both ORM and HR, they are not in the package name anymore). With new entity supertype, as well as repository supertypes and way of working.Rough example entity:
This will generate the following:
To recap:
Session
instead ofEntityManager
for Panache1&2 since that's what Quarkus switched to a while agoThere are tests for all this, but they're in Quarkus, and can only be merged once this gets merged. This is because @yrodiere gets an allergic skin reaction with cyclic dependencies, and assures me that the ORM CI now invokes the Quarkus CI, so even though you won't see the tests when you run them locally, they will eventually be run as part of the ORM CI.
Let me know what you think, @gavinking and if you want me to change anything.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.