[JIRA] (HHH-16108) NullPointerException when flushing a (simple) entity update for models with bytecode enhancement and multiple one-to-one associations (some lazy)
by Yoann Rodière (JIRA)
Yoann Rodière ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiY2IwMDUyOWE2... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16108?atlOrigin=eyJpIjoiY2IwMD... ) HHH-16108 ( https://hibernate.atlassian.net/browse/HHH-16108?atlOrigin=eyJpIjoiY2IwMD... ) NullPointerException when flushing a (simple) entity update for models with bytecode enhancement and multiple one-to-one associations (some lazy) ( https://hibernate.atlassian.net/browse/HHH-16108?atlOrigin=eyJpIjoiY2IwMD... )
Issue Type: Bug Assignee: Unassigned Components: bytecode-enhancement, hibernate-core Created: 26/Jan/2023 06:05 AM Fix Versions: 6.2.0 Priority: Major Reporter: Yoann Rodière ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
Fails on ORM 6.2, but not on 6.1.
I’ll add a reproducer in the comments.
With a model like this (cannot be simpler, unfortunately):
@Entity(name = "entitya" )
public static class EntityA {
@Id
private Integer id;
@OneToOne
private EntityA selfAssociation;
@OneToOne(mappedBy = "selfAssociation" )
private EntityA mappedSelfAssociation;
@OneToOne(mappedBy = "association1" , fetch = FetchType.LAZY)
private EntityB mappedAssociation1;
@OneToOne(mappedBy = "association2" , fetch = FetchType.LAZY)
private EntityB mappedAssociation2;
protected EntityA() {
}
public EntityA( Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public void setId( Integer id) {
this.id = id;
}
public EntityA getSelfAssociation() {
return selfAssociation;
}
public void setSelfAssociation(EntityA selfAssociation) {
this.selfAssociation = selfAssociation;
}
public EntityA getMappedSelfAssociation() {
return mappedSelfAssociation;
}
public void setMappedSelfAssociation(EntityA mappedSelfAssociation) {
this.mappedSelfAssociation = mappedSelfAssociation;
}
public EntityB getMappedAssociation1() {
return mappedAssociation1;
}
public void setMappedAssociation1(EntityB mappedAssociation1) {
this.mappedAssociation1 = mappedAssociation1;
}
public EntityB getMappedAssociation2() {
return mappedAssociation2;
}
public void setMappedAssociation2(EntityB mappedAssociation2) {
this.mappedAssociation2 = mappedAssociation2;
}
}
@Entity(name = "entityb" )
public static class EntityB {
@Id
private Integer id;
@OneToOne
private EntityA association1;
@OneToOne
private EntityA association2;
protected EntityB() {
}
public EntityB( Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public void setId( Integer id) {
this.id = id;
}
public EntityA getAssociation1() {
return association1;
}
public void setAssociation1(EntityA association1) {
this.association1 = association1;
}
public EntityA getAssociation2() {
return association2;
}
public void setAssociation2(EntityA association2) {
this.association2 = association2;
}
}
This will fail:
inTransaction( s -> {
EntityA entityA = s.get( EntityA.class, 1 );
EntityB entityB = new EntityB( 2 );
entityA.setMappedAssociation1( entityB );
entityB.setAssociation1( entityA );
s.persist( entityB );
} );
With the following exception:
java.lang.NullPointerException: Cannot invoke "org.hibernate.metamodel.mapping.SelectableMapping.isFormula()" because "selectable" is null
at org.hibernate.persister.entity.mutation.UpdateCoordinatorStandard.processSet(UpdateCoordinatorStandard.java:665)
at org.hibernate.persister.entity.mutation.UpdateCoordinatorStandard.processAttribute(UpdateCoordinatorStandard.java:640)
at org.hibernate.persister.entity.mutation.UpdateCoordinatorStandard.analyzeUpdateValues(UpdateCoordinatorStandard.java:600)
at org.hibernate.persister.entity.mutation.UpdateCoordinatorStandard.performUpdate(UpdateCoordinatorStandard.java:256)
at org.hibernate.persister.entity.mutation.UpdateCoordinatorStandard.coordinateUpdate(UpdateCoordinatorStandard.java:203)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2766)
at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:165)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:616)
at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:487)
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:484)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:358)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:127)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1412)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:485)
at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:2277)
at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:1942)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:426)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:169)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:267)
at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101)
at org.hibernate.testing.transaction.TransactionUtil2.inTransaction(TransactionUtil2.java:128)
at org.hibernate.testing.transaction.TransactionUtil2.lambda$inTransaction$0(TransactionUtil2.java:76)
at org.hibernate.testing.transaction.TransactionUtil2.inSession(TransactionUtil2.java:35)
at org.hibernate.testing.transaction.TransactionUtil2.inTransaction(TransactionUtil2.java:74)
at org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase.inTransaction(BaseNonConfigCoreFunctionalTestCase.java:590)
( https://hibernate.atlassian.net/browse/HHH-16108#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16108#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100214- sha1:634fa42 )
1 year, 8 months