NullPointerException in PersistentClass.createPrimaryKey() when using @PrimaryKeyJoinColumn

Description

When using the @Id, @OneToOne and @PrimaryKeyJoinColumn annotations on a property, MetadataBuilder.build() throws a NullPointerException from the following code path:

I could reproduce this issue using both Hibernate ORM 5.1.3 and 5.2.6.

According to the Java EE docs, the @PrimaryKeyJoinColumn annotation may be used in a OneToOne mapping in which the primary key of the referencing entity is used as a foreign key to the referenced entity.

It seems like RootClass.identifier is null during the second pass (see above), when reached from the following code path:

A self-contained demo is available in

, it's runnable with mvn clean test. The @PrimaryKeyJoinColumn annotation is present on the Child.Parent field, the Hibernate bootstrapping process is attempted in Main.main(). The @OneToOne annotation is not bidirectional, it only goes from the Child to the Parent.

Environment

None

Assignee

Unassigned

Reporter

Gábor Varga

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure