I don’t really know if this is a bug or working as intended, mybe someone can explain this behavior:
If I generate the entity classes with the JPA Reverse Engineering tools form a postgresql database it generates two files, one “default” class named like the table with an embedded id and one Id class with the actual table contents.
Example:
Database:
CREATE TABLE customer
(
email character varying NOT NULL,
prefix character varying NOT NULL,
firstname character varying(30),
lastname character varying(30),
....
)
Some index-fields, but pretty much a plain table.
Now the class looks like this:
customer.java:
@Entity
@Table(name = "customer", schema = "public", uniqueConstraints = @UniqueConstraint(columnNames = "id"))
public class Customer implements java.io.Serializable {
// Fields
private CustomerId id;
....
// Property accessors
@EmbeddedId
@AttributeOverrides( {
@AttributeOverride(name = "id", column = @Column(name = "id", unique = true, nullable = false)),
@AttributeOverride(name = "firstname", column = @Column(firstname = "firstname", nullable = false)),
customerid.java
@Embeddable
public class CustomerId implements java.io.Serializable {
// Fields
private Integer id;
private String firstname;
....
Is there a specific reason for that (splitting into two files with EmbeddedId) or am I missing something else?
Thanks in advance.