HHH-3868 Fix null pointer exception on merge of entity with transient component
This commit is contained in:
parent
83f29d1e1a
commit
c60c97b468
|
@ -680,6 +680,9 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
|||
@Override
|
||||
public Object proxyFor(Object impl) throws HibernateException {
|
||||
final EntityEntry e = getEntry( impl );
|
||||
if ( e == null ) {
|
||||
return impl;
|
||||
}
|
||||
return proxyFor( e.getPersister(), e.getEntityKey(), impl );
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -37,6 +38,7 @@ import org.hibernate.Transaction;
|
|||
import org.hibernate.test.annotations.embedded.FloatLeg.RateIndex;
|
||||
import org.hibernate.test.annotations.embedded.Leg.Frequency;
|
||||
import org.hibernate.test.util.SchemaUtil;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -517,6 +519,18 @@ public class EmbeddedTest extends BaseCoreFunctionalTestCase {
|
|||
s.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-3868")
|
||||
public void testTransientMergeComponentParent() {
|
||||
Session s = openSession();
|
||||
Transaction tx = s.beginTransaction();
|
||||
Book b = new Book();
|
||||
b.setIsbn( UUID.randomUUID().toString() );
|
||||
b.setSummary( new Summary() );
|
||||
b = (Book) session.merge( b );
|
||||
tx.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class[] getAnnotatedClasses() {
|
||||
return new Class[]{
|
||||
|
|
Loading…
Reference in New Issue