|
Hibernate example source code file (UnidirectionalMulIdWithNulls.java)
The Hibernate UnidirectionalMulIdWithNulls.java source codepackage org.hibernate.envers.test.integration.onetoone.unidirectional; import org.hibernate.ejb.Ejb3Configuration; import org.hibernate.envers.test.AbstractEntityTest; import org.hibernate.envers.test.Priority; import org.hibernate.envers.test.entities.ids.EmbId; import org.hibernate.envers.test.entities.ids.EmbIdTestEntity; import org.junit.Test; import javax.persistence.EntityManager; import static org.junit.Assert.*; /** * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) */ public class UnidirectionalMulIdWithNulls extends AbstractEntityTest { private EmbId ei; public void configure(Ejb3Configuration cfg) { cfg.addAnnotatedClass(EmbIdTestEntity.class); cfg.addAnnotatedClass(UniRefIngMulIdEntity.class); } @Test @Priority(10) public void initData() { ei = new EmbId(1, 2); EntityManager em = getEntityManager(); // Revision 1 EmbIdTestEntity eite = new EmbIdTestEntity(ei, "data"); UniRefIngMulIdEntity notNullRef = new UniRefIngMulIdEntity(1, "data 1", eite); UniRefIngMulIdEntity nullRef = new UniRefIngMulIdEntity(2, "data 2", null); em.getTransaction().begin(); em.persist(eite); em.persist(notNullRef); em.persist(nullRef); em.getTransaction().commit(); } @Test public void testNullReference() { UniRefIngMulIdEntity nullRef = getAuditReader().find(UniRefIngMulIdEntity.class, 2, 1); assertNull(nullRef.getReference()); } @Test public void testNotNullReference() { EmbIdTestEntity eite = getAuditReader().find(EmbIdTestEntity.class, ei, 1); UniRefIngMulIdEntity notNullRef = getAuditReader().find(UniRefIngMulIdEntity.class, 1, 1); assertNotNull(notNullRef.getReference()); assertEquals(notNullRef.getReference(), eite); } } Other Hibernate examples (source code examples)Here is a short list of links related to this Hibernate UnidirectionalMulIdWithNulls.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.