Hibernate Processor does not handle inner @Embeddable types
Description
Activity
Gavin King December 4, 2024 at 7:06 PM
Done by
Čedomir Igaly October 16, 2024 at 1:00 PM
I’ve created working version in PR #9098 , guess that it is far from perfection, but all tests are )at least mostly) passing.
One request is that inner class must not be private. Otherwise such classes are out of the reach for generated metamodel classes. I’ve changed access for inner classes in existing test cases from private to package where needed.
Also, there were two additional problems with existing test classes. In org.hibernate.orm.test.schematools.PrimaryKeyColumnOrderTest.TestEntity
there are two properties. Those were named A
and B
. Although this may be (or may be not?) legitimate, generated metamodel class will have two pairs of duplicate fields. And that surely is not legitimate for Java compiler
The other problem was org.hibernate.orm.test.hql.QuotedIdentifierTest.Person
. Entity is named `The Person`
. I guess that this surely is legitimate, but will cause problem with generation of entry in ındex` package (or directory, as you like it). Java is using that value as constructor argument to java.net.URI
, and this one does not like spaces. Easiest (but maybe not the best) solution was to URL encode entity names .
Čedomir Igaly October 8, 2024 at 7:08 AM
JPA 3.2 specification says “The entity class must be a top-level class or a static inner class”, so I guess that inner @Entites should be handled as well, right?
Also, specification does not say anything about metamodel classes generated from inner classes. Question is then how to handle such classes? Simplest option is to create separate metadata class for each class, either top level or inner. Other option is to generate metadata as inner class of some top level class metadata. Later option has problem that inner class containing managed class need not to be managed itself. I am afraid that this can make pretty nice mess
Gavin King October 7, 2024 at 6:03 PM
that would be awesome, thanks 🙏
Čedomir Igaly October 7, 2024 at 5:12 PM
If you are not already working on that, I can check something that I’ve been doing on that same problem. If I remember, that has been working, but with some things that I would like to check (and fix).
Hibernate allows an
@Embeddable
to be an innerclass
orrecord
of an entity class.Hibernate Processor breaks if you try to do this.