Auto generate record ID class if no explicit `@IdClass`
Given an entity meets:
- using composite primary key
- no
@IdClassannotated
For example:
@Entity
public class Employee {
@Id String empName;
@Id Date birthDay;
...
}
It would be convenient if a record class is generated as implicit @IdClass
public record EmployeeId(String empName, Date birthDay) {}
candidate names of generated record class:
- EmployeeId
- EmployeePK
- EmployeeId_
- EmployeePK_
- Employee$Id
- Employee$PK
It's an interesting idea.
candidate names of generated record class
I kinda hate those suggestions though :)
My knee-jerk would be an inner class of Book_, something like Book_.Id_ which does not collide with anything currently defined in 5.1.1. But it does have one potential problem in that in Hibernate Processor, IIRC, we have started using the convention X_.Y_ when you have a static inner class annotated @Entity (which is permitted by the spec, but currently not considered in 5.1.1). Right, @cigaly?
@gavinking Actually, what I've done was generating separate class file for each (static) inner class, so that X.Y will produce X_Y_. [But there should be not big problem to make it as inner class X_.Y_]
Why not generate something like Book_.Id [or Book_Id] by simply ommiting underscore at the end, so that distinction will be more clear?
I'm voting for Book_.Id.