|
Hibernate example source code file (ReadWriteExpressionChange.java)
The Hibernate ReadWriteExpressionChange.java source codepackage org.hibernate.envers.test.integration.readwriteexpression; import org.hibernate.ejb.Ejb3Configuration; import org.hibernate.envers.test.AbstractEntityTest; import org.hibernate.envers.test.Priority; import org.junit.Test; import javax.persistence.EntityManager; import java.util.List; public class ReadWriteExpressionChange extends AbstractEntityTest { private static final double HEIGHT_INCHES = 73; private static final double HEIGHT_CENTIMETERS = HEIGHT_INCHES * 2.54d; private Integer id; @Override public void configure(Ejb3Configuration cfg) { cfg.addAnnotatedClass(Staff.class); } @Test @Priority(10) public void initData() { EntityManager em = getEntityManager(); em.getTransaction().begin(); Staff staff = new Staff(HEIGHT_INCHES, 1); em.persist(staff); em.getTransaction().commit(); id = staff.getId(); } @Test public void shouldRespectWriteExpression() { EntityManager em = getEntityManager(); List resultList = em.createNativeQuery("select size_in_cm from t_staff_AUD where id ="+id).getResultList(); assert 1 == resultList.size(); Double sizeInCm = (Double) resultList.get(0); assert sizeInCm.equals(HEIGHT_CENTIMETERS); } @Test public void shouldRespectReadExpression() { List<Number> revisions = getAuditReader().getRevisions(Staff.class, id); assert 1 == revisions.size(); Number number = revisions.get(0); Staff staffRev = getAuditReader().find(Staff.class, id, number); assert HEIGHT_INCHES == staffRev.getSizeInInches(); } } Other Hibernate examples (source code examples)Here is a short list of links related to this Hibernate ReadWriteExpressionChange.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.