I have a Contact entity which has an optional unidirectional 1:1 association with an Address entity. Now, when I'm retrieving a version of Contact which doesn't have an Address from audit tables and trying to access the Address I'm getting: org.hibernate.ObjectNotFoundException: No row with the given identifier exists

org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.acme.model.address.Address#com.acme.model.address.AddressPK@143fd2a[ id=<null> ver=<null>]]

I found the following issue related to composite PK and @OneToOne opened in JIRA: HHH-5343 (Issue with lazy loading of composite key for 1:1 entity relationships). Maybe it's related to the same issue.

The row doesn't exists in DB because this is an optional 1:1 association. A Contact can have or can not have an Address. The Address is optional. If Contact has an address then everything is OK. In case the Contact doesn't have an Address, then while retrieving a revision for this Contact from audit tables the ObjectNotFoundException is raised when the contact address is accessed. In this case the address should be null, but instead Envers creates a proxy and tries to initialize it.