Search in sources :

Example 96 with EntityManager

use of javax.persistence.EntityManager in project hibernate-orm by hibernate.

the class NullProperties method addNewEntity.

private Integer addNewEntity(String str, long lng) {
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    BasicTestEntity1 bte1 = new BasicTestEntity1(str, lng);
    em.persist(bte1);
    em.getTransaction().commit();
    return bte1.getId();
}
Also used : EntityManager(javax.persistence.EntityManager)

Example 97 with EntityManager

use of javax.persistence.EntityManager in project hibernate-orm by hibernate.

the class ImmutableClassAccessType method initData.

@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();
}
Also used : EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 98 with EntityManager

use of javax.persistence.EntityManager in project hibernate-orm by hibernate.

the class PropertyAccessType method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    PropertyAccessTypeEntity pate = new PropertyAccessTypeEntity("data");
    em.persist(pate);
    id1 = pate.getId();
    em.getTransaction().commit();
    em.getTransaction().begin();
    pate = em.find(PropertyAccessTypeEntity.class, id1);
    pate.writeData("data2");
    em.getTransaction().commit();
}
Also used : EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 99 with EntityManager

use of javax.persistence.EntityManager in project hibernate-orm by hibernate.

the class AuditReaderAPITest method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    AuditedTestEntity ent1 = new AuditedTestEntity(1, "str1");
    NotAuditedTestEntity ent2 = new NotAuditedTestEntity(1, "str1");
    em.persist(ent1);
    em.persist(ent2);
    em.getTransaction().commit();
    em.getTransaction().begin();
    ent1 = em.find(AuditedTestEntity.class, 1);
    ent2 = em.find(NotAuditedTestEntity.class, 1);
    ent1.setStr1("str2");
    ent2.setStr1("str2");
    em.getTransaction().commit();
}
Also used : EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 100 with EntityManager

use of javax.persistence.EntityManager in project hibernate-orm by hibernate.

the class ColumnScalePrecisionTest method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    // Revision 1
    em.getTransaction().begin();
    ScalePrecisionEntity entity = new ScalePrecisionEntity(13.0);
    em.persist(entity);
    em.getTransaction().commit();
    id = entity.getId();
    auditTable = metadata().getEntityBinding("org.hibernate.envers.test.integration.basic.ScalePrecisionEntity_AUD").getTable();
    originalTable = metadata().getEntityBinding("org.hibernate.envers.test.integration.basic.ScalePrecisionEntity").getTable();
}
Also used : EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Aggregations

EntityManager (javax.persistence.EntityManager)1395 Test (org.junit.Test)876 Priority (org.hibernate.envers.test.Priority)249 Query (javax.persistence.Query)200 TestForIssue (org.hibernate.testing.TestForIssue)97 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)87 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)79 List (java.util.List)69 NoResultException (javax.persistence.NoResultException)65 AbstractMetamodelSpecificTest (org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest)63 EntityManagerFactory (javax.persistence.EntityManagerFactory)56 HashMap (java.util.HashMap)50 StrTestEntity (org.hibernate.envers.test.entities.StrTestEntity)50 ArrayList (java.util.ArrayList)41 PersistenceException (javax.persistence.PersistenceException)40 EntityNotFoundException (javax.persistence.EntityNotFoundException)39 Transactional (com.google.inject.persist.Transactional)38 EntityTransaction (javax.persistence.EntityTransaction)36 Item (org.hibernate.jpa.test.Item)36 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)34