alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Hibernate example source code file (ImmutableClassAccessType.java)

This example Hibernate source code file (ImmutableClassAccessType.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Hibernate tags/keywords

abstractentitytest, country, country, entitymanager, germany, immutableclassaccesstype, immutableclassaccesstype, priority, priority, test, test, util

The Hibernate ImmutableClassAccessType.java source code

package org.hibernate.envers.test.integration.accesstype;

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.Arrays;

import static org.junit.Assert.*;

public class ImmutableClassAccessType extends AbstractEntityTest {
	private Country country;

	public void configure(Ejb3Configuration cfg) {
		cfg.addAnnotatedClass(Country.class);
	}

	@Test
    @Priority(10)
	public void initData() {
		EntityManager em = getEntityManager();

		// Revision 1
		em.getTransaction().begin();
		country = Country.of(123, "Germany");
		em.persist(country);
		em.getTransaction().commit();

	}

	@Test
	public void testRevisionsCounts() {
		assert Arrays.asList(1)
				.equals(
						getAuditReader().getRevisions(Country.class,
								country.getCode()));
	}

	@Test
	public void testHistoryOfId1() {
		Country country1 = getEntityManager().find(Country.class,
				country.getCode());
		assertEquals(country1, country);

		Country history = getAuditReader().find(Country.class, country1.getCode(), 1);
		assertEquals(country, history);
	}

}

Other Hibernate examples (source code examples)

Here is a short list of links related to this Hibernate ImmutableClassAccessType.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.