javax.persistence.EntityManager

Here are the examples of the java api class javax.persistence.EntityManager taken from open source projects.

1. JtaRollbackTest#testManualRollback()

Project: hibernate-ogm
Source File: JtaRollbackTest.java
View license
@Test
public void testManualRollback() throws Exception {
    final Game game1 = new Game("game-1", "Title 1");
    TransactionManager transactionManager = getTransactionManager();
    transactionManager.begin();
    EntityManager em = getFactory().createEntityManager();
    em.persist(game1);
    em.flush();
    em.clear();
    transactionManager.commit();
    transactionManager.begin();
    em.joinTransaction();
    em.persist(new Game("game-2", "Title 2"));
    transactionManager.rollback();
    em.close();
    NodeForGraphAssertions gameNode1 = node("g1", Game.class.getSimpleName(), ENTITY.name()).property("id", game1.getId()).property("title", game1.getTitle());
    assertThatOnlyTheseNodesExist(gameNode1);
}

2. QueryWithParametersTest#insertTestEntities()

View license
private void insertTestEntities() throws Exception {
    EntityManager entityManager = emf.createEntityManager();
    entityManager.getTransaction().begin();
    entityManager.persist(new Movie("movie-1", Genre.COMEDY, "To thatch a roof", true, new GregorianCalendar(1955, 5, 10).getTime(), (byte) 8));
    entityManager.persist(new Movie("movie-2", Genre.THRILLER, "South by Southeast", true, new GregorianCalendar(1958, 3, 2).getTime(), (byte) 9));
    entityManager.persist(new Movie("movie-3", Genre.THRILLER, "Front Door", false, new GregorianCalendar(1961, 2, 23).getTime(), (byte) 7));
    entityManager.persist(new Movie("movie-4", Genre.DRAMA, "Barnie", false, new GregorianCalendar(1962, 11, 2).getTime(), (byte) 7));
    entityManager.getTransaction().commit();
    entityManager.close();
}

3. ResourceLocalRollbackTest#testManualRollback()

View license
@Test
public void testManualRollback() throws Exception {
    Game game1 = new Game("game-1", "Title 1");
    EntityManager em = getFactory().createEntityManager();
    em.getTransaction().begin();
    em.persist(game1);
    em.flush();
    em.clear();
    em.getTransaction().commit();
    em.getTransaction().begin();
    em.persist(new Game("game-2", "Title 2"));
    em.getTransaction().rollback();
    em.close();
    NodeForGraphAssertions gameNode1 = node("g1", Game.class.getSimpleName(), ENTITY.name()).property("id", game1.getId()).property("title", game1.getTitle());
    assertThatOnlyTheseNodesExist(gameNode1);
}

4. BidirectionalManyToOneTest#prepareDb()

View license
@Before
public void prepareDb() throws Exception {
    EntityManager em = getFactory().createEntityManager();
    em.getTransaction().begin();
    salesForce = new SalesForce("red_hat");
    salesForce.setCorporation("Red Hat");
    em.persist(salesForce);
    eric = new SalesGuy("eric");
    eric.setName("Eric");
    eric.setSalesForce(salesForce);
    salesForce.getSalesGuys().add(eric);
    em.persist(eric);
    simon = new SalesGuy("simon");
    simon.setName("Simon");
    simon.setSalesForce(salesForce);
    salesForce.getSalesGuys().add(simon);
    em.persist(simon);
    em.getTransaction().commit();
    em.close();
}

5. MapTest#prepareDb()

Project: hibernate-ogm
Source File: MapTest.java
View license
@Before
public void prepareDb() throws Exception {
    final EntityManager em = getFactory().createEntityManager();
    em.getTransaction().begin();
    home = new Address();
    home.setCity("Paris");
    work = new Address();
    work.setCity("San Francisco");
    user = new User();
    user.getAddresses().put("home", home);
    user.getAddresses().put("work", work);
    user.getNicknames().add("idrA");
    user.getNicknames().add("day[9]");
    em.persist(home);
    em.persist(work);
    em.persist(user);
    em.getTransaction().commit();
    em.close();
}

6. ReferencedCompositeIdTest#prepareDb()

View license
@Before
public void prepareDb() throws Exception {
    EntityManager em = getFactory().createEntityManager();
    em.getTransaction().begin();
    britishOpen = new Tournament(new TournamentId("US", "123"), "British Open");
    playersChampionship = new Tournament(new TournamentId("US", "456"), "Player's Championship");
    em.persist(britishOpen);
    em.persist(playersChampionship);
    director = new Director("bob", "Bob", playersChampionship);
    em.persist(director);
    em.getTransaction().commit();
    em.close();
}

7. UnidirectionalManyToOneTest#prepareDb()

View license
@Before
public void prepareDb() throws Exception {
    final EntityManager em = getFactory().createEntityManager();
    em.getTransaction().begin();
    jug = new JUG("summer_camp");
    jug.setName("JUG Summer Camp");
    em.persist(jug);
    emmanuel = new Member("emmanuel");
    emmanuel.setName("Emmanuel Bernard");
    emmanuel.setMemberOf(jug);
    jerome = new Member("jerome");
    jerome.setName("Jerome");
    jerome.setMemberOf(jug);
    em.persist(emmanuel);
    em.persist(jerome);
    em.getTransaction().commit();
    em.close();
}

8. CassandraScalarQueriesTest#setUp()

View license
/**
     * Sets the up.
     * 
     * @throws Exception
     *             the exception
     */
@BeforeClass
public static void setUp() throws Exception {
    CassandraCli.cassandraSetUp();
    CassandraCli.dropKeySpace("KunderaExamples");
    HashMap propertyMap = new HashMap();
    propertyMap.put(PersistenceProperties.KUNDERA_DDL_AUTO_PREPARE, "create");
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("genericCassandraTest", propertyMap);
    EntityManager em = emf.createEntityManager();
    Object p1 = prepareData("1", 10);
    Object p2 = prepareData("2", 20);
    Object p3 = prepareData("3", 15);
    em.persist(p1);
    em.persist(p2);
    em.persist(p3);
    emf.close();
    em.close();
    entityManagerFactory = Persistence.createEntityManagerFactory("CassandraScalarQueriesTest");
    entityManager = entityManagerFactory.createEntityManager();
}

9. CountersTest#incrCounter()

Project: Kundera
Source File: CountersTest.java
View license
public void incrCounter() {
    EntityManager em = emf.createEntityManager();
    Counters counter = new Counters();
    counter.setCounter(12);
    counter.setId(id1);
    em.persist(counter);
    Counters counter1 = new Counters();
    counter1.setCounter(15);
    counter1.setId(id2);
    em.persist(counter1);
    Counters counter2 = new Counters();
    counter2.setCounter(18);
    counter2.setId(id3);
    em.persist(counter2);
    em.close();
}

10. CountersTest#decrCounter()

Project: Kundera
Source File: CountersTest.java
View license
private void decrCounter() {
    EntityManager em = emf.createEntityManager();
    Counters counter1 = new Counters();
    counter1.setCounter(-10);
    counter1.setId(id1);
    em.persist(counter1);
    Counters counter2 = new Counters();
    counter2.setCounter(-10);
    counter2.setId(id2);
    em.persist(counter2);
    Counters counter3 = new Counters();
    counter3.setCounter(-10);
    counter3.setId(id3);
    em.persist(counter3);
    em.close();
}

11. JPAProcessorImplTest#getLocalEntityManager()

View license
public EntityManager getLocalEntityManager() {
    EntityManager em = EasyMock.createMock(EntityManager.class);
    EasyMock.expect(em.createQuery("SELECT E1 FROM SalesOrderHeaders E1")).andStubReturn(getQuery());
    EasyMock.expect(em.createQuery("SELECT COUNT ( E1 ) FROM SalesOrderHeaders E1")).andStubReturn(getQueryForSelectCount());
    // For Delete
    EasyMock.expect(em.getTransaction()).andStubReturn(getLocalTransaction());
    EasyMock.expect(em.isOpen()).andReturn(false);
    em.flush();
    em.flush();
    Address obj = new Address();
    // testing void method
    em.remove(obj);
    // testing void method
    em.remove(obj);
    EasyMock.replay(em);
    return em;
}

12. JPAVariableTest#setupIllegalJPAEntities()

View license
public void setupIllegalJPAEntities() {
    EntityManager manager = entityManagerFactory.createEntityManager();
    manager.getTransaction().begin();
    compoundIdJPAEntity = new CompoundIdJPAEntity();
    EmbeddableCompoundId id = new EmbeddableCompoundId();
    id.setIdPart1(123L);
    id.setIdPart2("part2");
    compoundIdJPAEntity.setId(id);
    manager.persist(compoundIdJPAEntity);
    manager.flush();
    manager.getTransaction().commit();
    manager.close();
}

13. FalconJPAService#init()

Project: falcon
Source File: FalconJPAService.java
View license
@Override
public void init() throws FalconException {
    Properties props = getPropsforStore();
    entityManagerFactory = Persistence.createEntityManagerFactory(persistenceUnit, props);
    EntityManager entityManager = getEntityManager();
    entityManager.find(EntityBean.class, 1);
    entityManager.find(InstanceBean.class, 1);
    LOG.info("All entities initialized");
    // need to use a pseudo no-op transaction so all entities, datasource
    // and connection pool are initialized one time only
    entityManager.getTransaction().begin();
    OpenJPAEntityManagerFactorySPI spi = (OpenJPAEntityManagerFactorySPI) entityManagerFactory;
    // Mask the password with '***'
    String logMsg = spi.getConfiguration().getConnectionProperties().replaceAll("Password=.*?,", "Password=***,");
    LOG.info("JPA configuration: {0}", logMsg);
    entityManager.getTransaction().commit();
    entityManager.close();
}

14. BidirectionalOneToOneTest#prepareDb()

View license
@Before
public void prepareDb() throws Exception {
    EntityManager em = getFactory().createEntityManager();
    em.getTransaction().begin();
    husband = new Husband("frederic");
    husband.setName("Frederic Joliot-Curie");
    wife = new Wife("wife");
    wife.setName("Irene Joliot-Curie");
    wife.setHusband(husband);
    husband.setWife(wife);
    em.persist(husband);
    em.persist(wife);
    em.getTransaction().commit();
    em.close();
}

15. JPAWorkItemHandlerTest#createOnProcessTest()

Project: jbpm
Source File: JPAWorkItemHandlerTest.java
View license
@Test
public void createOnProcessTest() throws Exception {
    String DESC = "Table";
    Product p = new Product(DESC, 10f);
    startJPAWIHProcess(JPAWorkItemHandler.CREATE_ACTION, p);
    UserTransaction ut = getUserTransaction();
    ut.begin();
    EntityManager em = emf.createEntityManager();
    TypedQuery<Product> products = em.createQuery("select p from Product p where p.description = :desc", Product.class);
    products.setParameter("desc", DESC);
    List<Product> resultList = products.getResultList();
    Product result = resultList.iterator().next();
    assertEquals(DESC, result.getDescription());
    em.remove(result);
    em.flush();
    em.close();
    ut.commit();
}

16. ExternalPropertyLoaderTest#test()

View license
/**
     * Junit to verify, if emf has been successfully loaded and user object has
     * been persisted.
     */
@Test
public void test() {
    EntityManager em = emf.createEntityManager();
    User user = new User();
    user.setFirstName("John");
    user.setLastName("Smith");
    user.setCity("London");
    em.persist(user);
    em.clear();
    // it is auto generated in-memory
    User found = em.find(User.class, user.getUserId());
    // id
    Assert.assertNotNull(found);
    Assert.assertEquals(user.getCity(), found.getCity());
    em.close();
}

17. CountersTest#deleteCounter()

Project: Kundera
Source File: CountersTest.java
View license
public void deleteCounter() {
    EntityManager em = emf.createEntityManager();
    Counters counters = new Counters();
    counters = em.find(Counters.class, id3);
    Assert.assertNotNull(counters);
    Assert.assertNotNull(counters.getCounter());
    em.remove(counters);
    EntityManager em1 = emf.createEntityManager();
    counters = em1.find(Counters.class, id3);
    Assert.assertNull(counters);
    em.close();
}

18. SuperCountersTest#deleteSuperCounter()

Project: Kundera
Source File: SuperCountersTest.java
View license
private void deleteSuperCounter() {
    EntityManager em = emf.createEntityManager();
    SuperCounters counter = new SuperCounters();
    counter = em.find(SuperCounters.class, id3);
    Assert.assertNotNull(counter);
    Assert.assertNotNull(counter.getCounter());
    Assert.assertNotNull(counter.getSubCounter());
    Assert.assertEquals(8, counter.getCounter());
    Assert.assertEquals(2225, counter.getlCounter());
    Assert.assertEquals(3, counter.getSubCounter().getSubCounter());
    em.remove(counter);
    EntityManager em1 = emf.createEntityManager();
    counter = em1.find(SuperCounters.class, id3);
    Assert.assertNull(counter);
    em.close();
}

19. StudentCassandraBooleanPrimitiveTest#testPersist()

View license
public void testPersist(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    // Insert max value of boolean
    StudentBooleanPrimitive studentMax = new StudentBooleanPrimitive();
    studentMax.setAge((Short) getMaxValue(short.class));
    studentMax.setId((Boolean) getMaxValue(boolean.class));
    studentMax.setName((String) getMaxValue(String.class));
    em.persist(studentMax);
    // Insert min value of boolean
    StudentBooleanPrimitive studentMin = new StudentBooleanPrimitive();
    studentMin.setAge((Short) getMinValue(short.class));
    studentMin.setId((Boolean) getMinValue(boolean.class));
    studentMin.setName((String) getMinValue(String.class));
    em.persist(studentMin);
    em.close();
}

20. StudentCassandraBooleanWrapperTest#testPersist()

View license
public void testPersist(Boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    // Insert max value of Boolean
    StudentBooleanWrapper studentMax = new StudentBooleanWrapper();
    studentMax.setAge((Short) getMaxValue(short.class));
    studentMax.setId((Boolean) getMaxValue(Boolean.class));
    studentMax.setName((String) getMaxValue(String.class));
    em.persist(studentMax);
    // Insert min value of Boolean
    StudentBooleanWrapper studentMin = new StudentBooleanWrapper();
    studentMin.setAge((Short) getMinValue(short.class));
    studentMin.setId((Boolean) getMinValue(Boolean.class));
    studentMin.setName((String) getMinValue(String.class));
    em.persist(studentMin);
    em.close();
}

21. CassandraScalarQueriesTest#setUp()

View license
/**
     * Sets the up.
     * 
     * @throws Exception
     *             the exception
     */
@BeforeClass
public static void setUp() throws Exception {
    CassandraCli.cassandraSetUp();
    CassandraCli.dropKeySpace("KunderaExamples");
    HashMap propertyMap = new HashMap();
    propertyMap.put(PersistenceProperties.KUNDERA_DDL_AUTO_PREPARE, "create");
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("dsscalar_entity", propertyMap);
    EntityManager em = emf.createEntityManager();
    Object p1 = prepareData("1", 10);
    Object p2 = prepareData("2", 20);
    Object p3 = prepareData("3", 15);
    em.persist(p1);
    em.persist(p2);
    em.persist(p3);
}

22. StudentCouchDBBooleanPrimitiveTest#testPersist()

View license
public void testPersist(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    // Insert max value of boolean
    StudentCouchDBBooleanPrimitive studentMax = new StudentCouchDBBooleanPrimitive();
    studentMax.setAge((Short) getMaxValue(short.class));
    studentMax.setId((Boolean) getMaxValue(boolean.class));
    studentMax.setName((String) getMaxValue(String.class));
    em.persist(studentMax);
    // Insert min value of boolean
    StudentCouchDBBooleanPrimitive studentMin = new StudentCouchDBBooleanPrimitive();
    studentMin.setAge((Short) getMinValue(short.class));
    studentMin.setId((Boolean) getMinValue(boolean.class));
    studentMin.setName((String) getMinValue(String.class));
    em.persist(studentMin);
    em.close();
}

23. StudentCouchDBBooleanWrapperTest#testPersist()

View license
public void testPersist(Boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    // Insert max value of Boolean
    StudentCouchDBBooleanWrapper studentMax = new StudentCouchDBBooleanWrapper();
    studentMax.setAge((Short) getMaxValue(short.class));
    studentMax.setId((Boolean) getMaxValue(Boolean.class));
    studentMax.setName((String) getMaxValue(String.class));
    em.persist(studentMax);
    // Insert min value of Boolean
    StudentCouchDBBooleanWrapper studentMin = new StudentCouchDBBooleanWrapper();
    studentMin.setAge((Short) getMinValue(short.class));
    studentMin.setId((Boolean) getMinValue(Boolean.class));
    studentMin.setName((String) getMinValue(String.class));
    em.persist(studentMin);
    em.close();
}

24. StudentHBaseBooleanPrimitiveTest#testPersist()

View license
public void testPersist(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    // Insert max value of boolean
    StudentHBaseBooleanPrimitive studentMax = new StudentHBaseBooleanPrimitive();
    studentMax.setAge((Short) getMaxValue(short.class));
    studentMax.setId((Boolean) getMaxValue(boolean.class));
    studentMax.setName((String) getMaxValue(String.class));
    em.persist(studentMax);
    // Insert min value of boolean
    StudentHBaseBooleanPrimitive studentMin = new StudentHBaseBooleanPrimitive();
    studentMin.setAge((Short) getPartialValue(short.class));
    studentMin.setId((Boolean) getMinValue(boolean.class));
    studentMin.setName((String) getMinValue(String.class));
    em.persist(studentMin);
    em.close();
}

25. StudentHBaseBooleanWrapperTest#testPersist()

View license
public void testPersist(Boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    // Insert max value of Boolean
    StudentHBaseBooleanWrapper studentMax = new StudentHBaseBooleanWrapper();
    studentMax.setAge((Short) getMaxValue(short.class));
    studentMax.setId((Boolean) getMaxValue(Boolean.class));
    studentMax.setName((String) getMaxValue(String.class));
    em.persist(studentMax);
    // Insert min value of Boolean
    StudentHBaseBooleanWrapper studentMin = new StudentHBaseBooleanWrapper();
    studentMin.setAge((Short) getPartialValue(short.class));
    studentMin.setId((Boolean) getMinValue(Boolean.class));
    studentMin.setName((String) getMinValue(String.class));
    em.persist(studentMin);
    em.close();
}

26. StudentHBaseBooleanPrimitiveTest#persistStudents()

View license
/**
     * Persist students.
     */
public void persistStudents() {
    EntityManager em = emf.createEntityManager();
    // Insert max value of boolean
    StudentHBaseBooleanPrimitive studentMax = new StudentHBaseBooleanPrimitive();
    studentMax.setAge((Short) getMaxValue(short.class));
    studentMax.setId((Boolean) getMaxValue(boolean.class));
    studentMax.setName((String) getMaxValue(String.class));
    em.persist(studentMax);
    // Insert min value of boolean
    StudentHBaseBooleanPrimitive studentMin = new StudentHBaseBooleanPrimitive();
    studentMin.setAge((Short) getPartialValue(short.class));
    studentMin.setId((Boolean) getMinValue(boolean.class));
    studentMin.setName((String) getMinValue(String.class));
    em.persist(studentMin);
    em.close();
}

27. StudentHBaseBooleanWrapperTest#persistStudents()

View license
/**
     * Persist students.
     */
public void persistStudents() {
    EntityManager em = emf.createEntityManager();
    // Insert max value of Boolean
    StudentHBaseBooleanWrapper studentMax = new StudentHBaseBooleanWrapper();
    studentMax.setAge((Short) getMaxValue(short.class));
    studentMax.setId((Boolean) getMaxValue(Boolean.class));
    studentMax.setName((String) getMaxValue(String.class));
    em.persist(studentMax);
    // Insert min value of Boolean
    StudentHBaseBooleanWrapper studentMin = new StudentHBaseBooleanWrapper();
    studentMin.setAge((Short) getPartialValue(short.class));
    studentMin.setId((Boolean) getMinValue(Boolean.class));
    studentMin.setName((String) getMinValue(String.class));
    em.persist(studentMin);
    em.close();
}

28. StudentMongoBooleanPrimitiveTest#testPersist()

View license
public void testPersist(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    // Insert max value of boolean
    StudentMongoBooleanPrimitive studentMax = new StudentMongoBooleanPrimitive();
    studentMax.setAge((Short) getMaxValue(short.class));
    studentMax.setId((Boolean) getMaxValue(boolean.class));
    studentMax.setName((String) getMaxValue(String.class));
    em.persist(studentMax);
    // Insert min value of boolean
    StudentMongoBooleanPrimitive studentMin = new StudentMongoBooleanPrimitive();
    studentMin.setAge((Short) getMinValue(short.class));
    studentMin.setId((Boolean) getMinValue(boolean.class));
    studentMin.setName((String) getMinValue(String.class));
    em.persist(studentMin);
    em.close();
}

29. StudentMongoBooleanWrapperTest#testPersist()

View license
public void testPersist(Boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    // Insert max value of Boolean
    StudentMongoBooleanWrapper studentMax = new StudentMongoBooleanWrapper();
    studentMax.setAge((Short) getMaxValue(short.class));
    studentMax.setId((Boolean) getMaxValue(Boolean.class));
    studentMax.setName((String) getMaxValue(String.class));
    em.persist(studentMax);
    // Insert min value of Boolean
    StudentMongoBooleanWrapper studentMin = new StudentMongoBooleanWrapper();
    studentMin.setAge((Short) getMinValue(short.class));
    studentMin.setId((Boolean) getMinValue(Boolean.class));
    studentMin.setName((String) getMinValue(String.class));
    em.persist(studentMin);
    em.close();
}

30. StudentRdbmsBooleanPrimitiveTest#testPersist()

View license
public void testPersist(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    // Insert max value of boolean
    StudentBooleanPrimitive studentMax = new StudentBooleanPrimitive();
    studentMax.setAge((Short) getMaxValue(short.class));
    studentMax.setId((Boolean) getMaxValue(boolean.class));
    studentMax.setName((String) getMaxValue(String.class));
    em.persist(studentMax);
    // Insert min value of boolean
    StudentBooleanPrimitive studentMin = new StudentBooleanPrimitive();
    studentMin.setAge((Short) getMinValue(short.class));
    studentMin.setId((Boolean) getMinValue(boolean.class));
    studentMin.setName((String) getMinValue(String.class));
    em.persist(studentMin);
    em.close();
}

31. StudentRdbmsBooleanWrapperTest#testPersist()

View license
public void testPersist(Boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    // Insert max value of Boolean
    StudentBooleanWrapper studentMax = new StudentBooleanWrapper();
    studentMax.setAge((Short) getMaxValue(short.class));
    studentMax.setId((Boolean) getMaxValue(Boolean.class));
    studentMax.setName((String) getMaxValue(String.class));
    em.persist(studentMax);
    // Insert min value of Boolean
    StudentBooleanWrapper studentMin = new StudentBooleanWrapper();
    studentMin.setAge((Short) getMinValue(short.class));
    studentMin.setId((Boolean) getMinValue(Boolean.class));
    studentMin.setName((String) getMinValue(String.class));
    em.persist(studentMin);
    em.close();
}

32. ODataJPAProcessorDefaultTest#getLocalEntityManager()

View license
private EntityManager getLocalEntityManager() {
    EntityManager em = EasyMock.createMock(EntityManager.class);
    EasyMock.expect(em.createQuery("SELECT E1 FROM SalesOrderHeaders E1")).andStubReturn(getQuery());
    EasyMock.expect(em.createQuery("SELECT COUNT ( E1 ) FROM SalesOrderHeaders E1")).andStubReturn(getQueryForSelectCount());
    // For create
    EasyMock.expect(em.getEntityManagerFactory()).andStubReturn(mockEntityManagerFactory2());
    // For Delete
    EasyMock.expect(em.getTransaction()).andStubReturn(getLocalTransaction());
    EasyMock.expect(em.isOpen()).andReturn(true).anyTimes();
    Address obj = new Address();
    // testing void method
    em.remove(obj);
    em.flush();
    em.close();
    EasyMock.expectLastCall().anyTimes();
    EasyMock.replay(em);
    return em;
}

33. JpaProducerRemoveTest#testRouteJpa()

Project: camel
Source File: JpaProducerRemoveTest.java
View license
@Test
public void testRouteJpa() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    context.startRoute("foo");
    context.startRoute("foo1");
    JpaEndpoint jpa = context.getEndpoint("jpa://" + SendEmail.class.getName(), JpaEndpoint.class);
    EntityManagerFactory emf = jpa.getEntityManagerFactory();
    EntityManager entityManager = emf.createEntityManager();
    template.sendBody("direct:start", new SendEmail("foo@beer.org"));
    Exchange exchange = mock.getReceivedExchanges().get(0);
    SendEmail persistedEntity = exchange.getIn().getBody(SendEmail.class);
    SendEmail emfindEntity = entityManager.find(SendEmail.class, persistedEntity.getId());
    assertNotSame(emfindEntity, persistedEntity);
    entityManager.close();
    mock.reset();
    entityManager = emf.createEntityManager();
    template.sendBody("direct:remove", new SendEmail("foo@beer.org"));
    exchange = mock.getReceivedExchanges().get(0);
    persistedEntity = exchange.getIn().getBody(SendEmail.class);
    emfindEntity = entityManager.find(SendEmail.class, persistedEntity.getId());
    assertNull(emfindEntity);
    entityManager.close();
}

34. OpenJPAJCacheDataCacheTest#entity()

View license
@Test
public void entity() {
    final EntityManagerFactory emf = Persistence.createEntityManagerFactory("test-jcache", props);
    final OpenJPAConfiguration conf = OpenJPAEntityManagerFactorySPI.class.cast(emf).getConfiguration();
    final EntityManager em = emf.createEntityManager();
    final MyEntity entity = new MyEntity();
    entity.setName("cacheMe1");
    em.getTransaction().begin();
    em.persist(entity);
    em.getTransaction().commit();
    assertNotNull(conf.getDataCacheManagerInstance().getDataCache("default"));
    assertThat(conf.getDataCacheManagerInstance(), instanceOf(OpenJPAJCacheDataCacheManager.class));
    assertThat(conf.getDataCacheManagerInstance().getDataCache("default"), instanceOf(OpenJPAJCacheDataCache.class));
    assertTrue(conf.getDataCacheManagerInstance().getDataCache("default").contains(JPAFacadeHelper.toOpenJPAObjectId(conf.getMetaDataRepositoryInstance().getCachedMetaData(MyEntity.class), entity.getId())));
    em.close();
    emf.close();
}

35. JPAAPIWrappingTest#testWrappedStandalone()

View license
@Test
public void testWrappedStandalone() throws Exception {
    final EntityManagerFactory emf = Persistence.createEntityManagerFactory("ogm", TestHelper.getDefaultTestSettings());
    assertThat(emf.getClass()).isEqualTo(OgmEntityManagerFactory.class);
    EntityManager em = emf.createEntityManager();
    assertThat(em.getClass()).isEqualTo(OgmEntityManager.class);
    em.close();
    em = emf.createEntityManager();
    assertThat(em.getClass()).isEqualTo(OgmEntityManager.class);
    em.close();
    emf.close();
}

36. BidirectionalManyToManyTest#prepareDb()

View license
@Before
public void prepareDb() throws Exception {
    EntityManager em = getFactory().createEntityManager();
    em.getTransaction().begin();
    owner = new AccountOwner("owner_1");
    owner.setSSN("0123456");
    soge = new BankAccount("account_1");
    soge.setAccountNumber("X2345000");
    soge.getOwners().add(owner);
    owner.getBankAccounts().add(soge);
    barclays = new BankAccount("account_2");
    barclays.setAccountNumber("ZZZ-009");
    barclays.getOwners().add(owner);
    owner.getBankAccounts().add(barclays);
    em.persist(owner);
    em.getTransaction().commit();
    em.close();
}

37. ElementCollectionListWithIndexTest#prepareDb()

View license
@Before
public void prepareDb() throws Exception {
    EntityManager em = getFactory().createEntityManager();
    em.getTransaction().begin();
    luke = new GrandChild();
    luke.setName("Luke");
    leia = new GrandChild();
    leia.setName("Leia");
    granny = new GrandMother();
    granny.getGrandChildren().add(luke);
    granny.getGrandChildren().add(leia);
    em.persist(granny);
    em.getTransaction().commit();
    em.close();
}

38. EmbeddableTest#prepareDB()

Project: hibernate-ogm
Source File: EmbeddableTest.java
View license
@Before
public void prepareDB() throws Exception {
    final EntityManager em = getFactory().createEntityManager();
    em.getTransaction().begin();
    account = new Account();
    account.setLogin("emmanuel");
    account.setPassword("like I would tell ya");
    account.setHomeAddress(new Address());
    address = account.getHomeAddress();
    address.setCity("Paris");
    address.setCountry("France");
    address.setStreet1("1 avenue des Champs Elysees");
    address.setZipCode("75007");
    address.setType(new AddressType("HOME"));
    em.persist(account);
    em.getTransaction().commit();
    em.close();
}

39. EmbeddableTest#testRemoveEmbeddedWhenOwnerIsRemoved()

Project: hibernate-ogm
Source File: EmbeddableTest.java
View license
@Test
public void testRemoveEmbeddedWhenOwnerIsRemoved() throws Exception {
    final EntityManager em = getFactory().createEntityManager();
    em.getTransaction().begin();
    Account found = em.find(Account.class, account.getLogin());
    em.remove(found);
    em.getTransaction().commit();
    em.close();
    assertNumberOfNodes(0);
    assertNumberOfRelationships(0);
}

40. EmbeddableWithCollectionMappingTest#prepareDB()

View license
@Before
public void prepareDB() throws Exception {
    final EntityManager em = getFactory().createEntityManager();
    em.getTransaction().begin();
    Order order = new Order("order-1", "Telescope", new ShippingAddress(new PhoneNumber("+1-222-555-0111", Arrays.asList("+1-222-555-0222", "+1-202-555-0333")), "Planet road 68"));
    em.persist(order);
    em.getTransaction().commit();
    em.close();
}

41. UnidirectionalManyToManyTest#prepareDb()

View license
@Before
public void prepareDb() throws Exception {
    final EntityManager em = getFactory().createEntityManager();
    em.getTransaction().begin();
    owner = new AccountOwner("owner_1");
    owner.setSSN("0123456");
    soge = new BankAccount("account_1");
    soge.setAccountNumber("X2345000");
    soge.getOwners().add(owner);
    owner.getBankAccounts().add(soge);
    barclays = new BankAccount("account_2");
    barclays.setAccountNumber("ZZZ-009");
    barclays.getOwners().add(owner);
    owner.getBankAccounts().add(barclays);
    em.persist(owner);
    em.getTransaction().commit();
    em.close();
}

42. UniqueConstraintCanBeSkippedTest#setup()

View license
@Before
public void setup() throws Exception {
    final EntityManager em = getFactory().createEntityManager();
    em.getTransaction().begin();
    entityWithConstraints = new EntityWithConstraints();
    entityWithConstraints.setId("id_1");
    entityWithConstraints.setUniqueColumn(12345678);
    em.persist(entityWithConstraints);
    em.getTransaction().commit();
    em.close();
}

43. UniqueConstraintTest#setup()

View license
@Before
public void setup() throws Exception {
    final EntityManager em = getFactory().createEntityManager();
    em.getTransaction().begin();
    entityWithConstraints = new EntityWithConstraints();
    entityWithConstraints.setId("johndoe");
    entityWithConstraints.setUniqueColumn(12345678);
    entityWithConstraints.setNaturalId("John Doe");
    entityWithConstraints.setTableConstraint("unique");
    entityWithConstraints.setNonUniqueProperty("no constraints here");
    em.persist(entityWithConstraints);
    em.getTransaction().commit();
    em.close();
}

44. UniqueConstraintTest#shouldNotCreateConstraintForNonUniqueProperty()

View license
@Test
public // Not expecting any exception
void shouldNotCreateConstraintForNonUniqueProperty() throws Exception {
    final EntityManager em = getFactory().createEntityManager();
    em.getTransaction().begin();
    EntityWithConstraints duplicated = new EntityWithConstraints();
    duplicated.setId("login4");
    duplicated.setNonUniqueProperty(entityWithConstraints.getNonUniqueProperty());
    em.persist(duplicated);
    em.getTransaction().commit();
    em.close();
}

45. HibernateOgmFindBenchmark#findEntityById()

View license
@Benchmark
@OperationsPerInvocation(OPERATIONS_PER_INVOCATION)
public void findEntityById(TestDataInserter inserter, Blackhole blackhole) throws Exception {
    EntityManagerFactoryHolder stateHolder = inserter.stateHolder;
    EntityManager entityManager = stateHolder.entityManagerFactory.createEntityManager();
    stateHolder.transactionManager.begin();
    entityManager.joinTransaction();
    for (int i = 0; i < OPERATIONS_PER_INVOCATION; i++) {
        long id = stateHolder.rand.nextInt(NUMBER_OF_TEST_ENTITIES - 1) + 1;
        AuthorWithSequence author = entityManager.find(AuthorWithSequence.class, id);
        if (author == null) {
            throw new IllegalArgumentException("Couldn't find entry with id " + id);
        }
        blackhole.consume(author.getLname());
    }
    stateHolder.transactionManager.commit();
    entityManager.close();
}

46. HibernateOgmInsertBenchmark#insertEntitiesUsingIdentity()

View license
@Benchmark
@OperationsPerInvocation(OPERATIONS_PER_INVOCATION)
public void insertEntitiesUsingIdentity(EntityManagerFactoryHolder stateHolder) throws Exception {
    EntityManager entityManager = stateHolder.entityManagerFactory.createEntityManager();
    stateHolder.transactionManager.begin();
    entityManager.joinTransaction();
    for (int i = 0; i < OPERATIONS_PER_INVOCATION; i++) {
        Author author = new Author();
        author.setBio("This is a decent size bio made of " + stateHolder.rand.nextDouble() + " stuffs");
        author.setDob(new Date());
        author.setFname("Jessie " + stateHolder.rand.nextInt());
        author.setLname("Landis " + stateHolder.rand.nextInt());
        author.setMname("" + stateHolder.rand.nextInt(26));
        entityManager.persist(author);
    }
    stateHolder.transactionManager.commit();
    entityManager.close();
}

47. HibernateOgmInsertBenchmark#doInsertEntitiesUsingSequence()

View license
private void doInsertEntitiesUsingSequence(EntityManagerFactoryHolder stateHolder) throws Exception {
    EntityManager entityManager = stateHolder.entityManagerFactory.createEntityManager();
    stateHolder.transactionManager.begin();
    entityManager.joinTransaction();
    for (int i = 0; i < OPERATIONS_PER_INVOCATION; i++) {
        AuthorWithSequence author = new AuthorWithSequence();
        author.setBio("This is a decent size bio made of " + stateHolder.rand.nextDouble() + " stuffs");
        author.setDob(new Date());
        author.setFname("Jessie " + stateHolder.rand.nextInt());
        author.setLname("Landis " + stateHolder.rand.nextInt());
        author.setMname("" + stateHolder.rand.nextInt(26));
        entityManager.persist(author);
    }
    stateHolder.transactionManager.commit();
    entityManager.close();
}

48. CorrelationPersistenceTest#before()

View license
@Before
public void before() throws Exception {
    context = setupWithPoolingDataSource(JBPM_PERSISTENCE_UNIT_NAME);
    CorrelationKeyFactory factory = KieInternalServices.Factory.get().newCorrelationKeyFactory();
    // populate table with test data
    EntityManagerFactory emf = (EntityManagerFactory) context.get(EnvironmentName.ENTITY_MANAGER_FACTORY);
    UserTransaction ut = InitialContext.doLookup("java:comp/UserTransaction");
    ut.begin();
    EntityManager em = emf.createEntityManager();
    em.persist(factory.newCorrelationKey("test123"));
    List<String> props = new ArrayList<String>();
    props.add("test123");
    props.add("123test");
    em.persist(factory.newCorrelationKey(props));
    ut.commit();
}

49. JPAWorkItemHandlerTest#removeOnProcessTest()

Project: jbpm
Source File: JPAWorkItemHandlerTest.java
View license
@Test
public void removeOnProcessTest() throws Exception {
    Product p = new Product("A Product", 10f);
    ut.begin();
    EntityManager em = emf.createEntityManager();
    em.persist(p);
    long id = p.getId();
    em.close();
    ut.commit();
    startJPAWIHProcess(JPAWorkItemHandler.DELETE_ACTION, p);
    ut.begin();
    em = emf.createEntityManager();
    p = em.find(Product.class, id);
    assertNull(p);
    ut.commit();
}

50. JPAWorkItemHandlerTest#updateOnProcessTest()

Project: jbpm
Source File: JPAWorkItemHandlerTest.java
View license
@Test
public void updateOnProcessTest() throws Exception {
    String DESC = "Table";
    String NEW_DESC = "Red Table";
    Product p = new Product(DESC, 10f);
    ut.begin();
    EntityManager em = emf.createEntityManager();
    em.persist(p);
    long id = p.getId();
    em.close();
    ut.commit();
    p.setDescription(NEW_DESC);
    startJPAWIHProcess(JPAWorkItemHandler.UPDATE_ACTION, p);
    ut.begin();
    em = emf.createEntityManager();
    p = em.find(Product.class, id);
    assertEquals(p.getDescription(), NEW_DESC);
    ut.commit();
    removeProduct(p);
}

51. SuperCountersTest#deleteNamedQueryOnCounter()

Project: Kundera
Source File: SuperCountersTest.java
View license
private void deleteNamedQueryOnCounter() {
    EntityManager em = emf.createEntityManager();
    String deleteQuery = "Delete From SuperCounters c where c.id <= " + id2;
    Query q = em.createQuery(deleteQuery);
    q.executeUpdate();
    em.clear();
    SuperCounters counter2 = new SuperCounters();
    counter2 = em.find(SuperCounters.class, id1);
    Assert.assertNull(counter2);
    SuperCounters counter3 = new SuperCounters();
    counter3 = em.find(SuperCounters.class, id2);
    Assert.assertNull(counter3);
    em.close();
}

52. StudentCassandraBigDecimalTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentBigDecimal studentMax = em.find(StudentBigDecimal.class, getMaxValue(BigDecimal.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentBigDecimal.class, getMaxValue(BigDecimal.class));
    Assert.assertNull(studentMax);
    em.close();
}

53. StudentCassandraBigIntegerTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentBigInteger studentMax = em.find(StudentBigInteger.class, getMaxValue(BigInteger.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentBigInteger.class, getMaxValue(BigInteger.class));
    Assert.assertNull(studentMax);
    em.close();
}

54. StudentCassandraBooleanPrimitiveTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentBooleanPrimitive studentMax = em.find(StudentBooleanPrimitive.class, getMinValue(boolean.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMinValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentBooleanPrimitive.class, getMinValue(boolean.class));
    Assert.assertNull(studentMax);
    em.close();
}

55. StudentCassandraBooleanWrapperTest#testDelete()

View license
public void testDelete(Boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentBooleanWrapper studentMax = em.find(StudentBooleanWrapper.class, getMinValue(Boolean.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMinValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentBooleanWrapper.class, getMinValue(Boolean.class));
    Assert.assertNull(studentMax);
    em.close();
}

56. StudentCassandraBytePrimitiveTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentBytePrimitive studentMax = em.find(StudentBytePrimitive.class, getMaxValue(byte.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentBytePrimitive.class, getMaxValue(byte.class));
    Assert.assertNull(studentMax);
    em.close();
}

57. StudentCassandraByteWrapperTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentByteWrapper studentMax = em.find(StudentByteWrapper.class, getMaxValue(Byte.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentByteWrapper.class, getMaxValue(Byte.class));
    Assert.assertNull(studentMax);
    em.close();
}

58. StudentCassandraCharacterTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCharacter studentMax = em.find(StudentCharacter.class, getMaxValue(Character.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCharacter.class, getMaxValue(Character.class));
    Assert.assertNull(studentMax);
    em.close();
}

59. StudentCassandraCharTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentChar studentMax = em.find(StudentChar.class, getMaxValue(char.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentChar.class, getMaxValue(char.class));
    Assert.assertNull(studentMax);
    em.close();
}

60. StudentCassandraDateTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentDate studentMax = em.find(StudentDate.class, getMaxValue(Date.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentDate.class, getMaxValue(Date.class));
    Assert.assertNull(studentMax);
    em.close();
}

61. StudentCassandraDoublePrimitiveTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentDoublePrimitive studentMax = em.find(StudentDoublePrimitive.class, getMaxValue(Double.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentDoublePrimitive.class, getMaxValue(Double.class));
    Assert.assertNull(studentMax);
    em.close();
}

62. StudentCassandraDoubleWrapperTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentDoubleWrapper studentMax = em.find(StudentDoubleWrapper.class, getMaxValue(Double.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentDoubleWrapper.class, getMaxValue(Double.class));
    Assert.assertNull(studentMax);
    em.close();
}

63. StudentCassandraFloatPrimitiveTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentFloatPrimitive studentMax = em.find(StudentFloatPrimitive.class, getMaxValue(float.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentFloatPrimitive.class, getMaxValue(float.class));
    Assert.assertNull(studentMax);
    em.close();
}

64. StudentCassandraFloatWrapperTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentFloatWrapper studentMax = em.find(StudentFloatWrapper.class, getMaxValue(Float.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentFloatWrapper.class, getMaxValue(Float.class));
    Assert.assertNull(studentMax);
    em.close();
}

65. StudentCassandraIntegerTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentInteger studentMax = em.find(StudentInteger.class, getMaxValue(Integer.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentInteger.class, getMaxValue(Integer.class));
    Assert.assertNull(studentMax);
    em.close();
}

66. StudentCassandraIntTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentInt studentMax = em.find(StudentInt.class, getMaxValue(int.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentInt.class, getMaxValue(int.class));
    Assert.assertNull(studentMax);
    testPersist(useSameEm);
    em.close();
}

67. StudentCassandraLongPrimitiveTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentLongPrimitive studentMax = em.find(StudentLongPrimitive.class, getMaxValue(long.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentLongPrimitive.class, getMaxValue(long.class));
    Assert.assertNull(studentMax);
    em.close();
}

68. StudentCassandraLongWrapperTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentLongWrapper studentMax = em.find(StudentLongWrapper.class, getMaxValue(Long.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentLongWrapper.class, getMaxValue(Long.class));
    Assert.assertNull(studentMax);
    em.close();
}

69. StudentCassandraShortPrimitiveTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentShortPrimitive studentMax = em.find(StudentShortPrimitive.class, getMaxValue(Short.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentShortPrimitive.class, getMaxValue(Short.class));
    Assert.assertNull(studentMax);
    em.close();
}

70. StudentCassandraShortWrapperTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentShortWrapper studentMax = em.find(StudentShortWrapper.class, getMaxValue(Short.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentShortWrapper.class, getMaxValue(Short.class));
    Assert.assertNull(studentMax);
    em.close();
}

71. StudentCassandraSqlDateTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentSqlDate studentMax = em.find(StudentSqlDate.class, getMaxValue());
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentSqlDate.class, getMaxValue());
    Assert.assertNull(studentMax);
    em.close();
}

72. StudentCassandraStringTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentString studentMax = em.find(StudentString.class, getMaxValue(String.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentString.class, getMaxValue(String.class));
    Assert.assertNull(studentMax);
    em.close();
}

73. StudentCassandraTimestampTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentTimestamp studentMax = em.find(StudentTimestamp.class, getMaxValue(Timestamp.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentTimestamp.class, getMaxValue(Timestamp.class));
    Assert.assertNull(studentMax);
    em.close();
}

74. StudentCassandraTimeTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentTime studentMax = em.find(StudentTime.class, getMaxValue(Time.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentTime.class, getMaxValue(Time.class));
    Assert.assertNull(studentMax);
    em.close();
}

75. StudentCassandraUUIDTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentUUID studentMax = em.find(StudentUUID.class, getMaxValue(UUID.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentUUID.class, getMaxValue(UUID.class));
    Assert.assertNull(studentMax);
    em.close();
}

76. CassandraGeneratedIdTest#testPersist()

View license
@Test
public void testPersist() {
    EntityManager em = emf.createEntityManager();
    CassandraGeneratedIdDefault idDefault = new CassandraGeneratedIdDefault();
    idDefault.setName("kuldeep");
    em.persist(idDefault);
    CassandraGeneratedIdStrategyAuto strategyAuto = new CassandraGeneratedIdStrategyAuto();
    strategyAuto.setName("kuldeep");
    em.persist(strategyAuto);
}

77. StudentCouchDBBigDecimalTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBBigDecimal studentMax = em.find(StudentCouchDBBigDecimal.class, getMaxValue(BigDecimal.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBBigDecimal.class, getMaxValue(BigDecimal.class));
    Assert.assertNull(studentMax);
    em.close();
}

78. StudentCouchDBBigIntegerTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBBigInteger studentMax = em.find(StudentCouchDBBigInteger.class, getMaxValue(BigInteger.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBBigInteger.class, getMaxValue(BigInteger.class));
    Assert.assertNull(studentMax);
    em.close();
}

79. StudentCouchDBBooleanPrimitiveTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBBooleanPrimitive studentMax = em.find(StudentCouchDBBooleanPrimitive.class, getMinValue(boolean.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMinValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBBooleanPrimitive.class, getMinValue(boolean.class));
    Assert.assertNull(studentMax);
    em.close();
}

80. StudentCouchDBBooleanWrapperTest#testDelete()

View license
public void testDelete(Boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBBooleanWrapper studentMax = em.find(StudentCouchDBBooleanWrapper.class, getMinValue(Boolean.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMinValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBBooleanWrapper.class, getMinValue(Boolean.class));
    Assert.assertNull(studentMax);
    em.close();
}

81. StudentCouchDBBytePrimitiveTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBBytePrimitive studentMax = em.find(StudentCouchDBBytePrimitive.class, getMaxValue(byte.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBBytePrimitive.class, getMaxValue(byte.class));
    Assert.assertNull(studentMax);
    em.close();
}

82. StudentCouchDBByteWrapperTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBByteWrapper studentMax = em.find(StudentCouchDBByteWrapper.class, getMaxValue(Byte.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBByteWrapper.class, getMaxValue(Byte.class));
    Assert.assertNull(studentMax);
    em.close();
}

83. StudentCouchDBCharacterTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBCharacter studentMax = em.find(StudentCouchDBCharacter.class, getMaxValue(Character.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBCharacter.class, getMaxValue(Character.class));
    Assert.assertNull(studentMax);
    em.close();
}

84. StudentCouchDBCharTest#testDelete()

Project: Kundera
Source File: StudentCouchDBCharTest.java
View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBChar studentMax = em.find(StudentCouchDBChar.class, getMaxValue(char.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBChar.class, getMaxValue(char.class));
    Assert.assertNull(studentMax);
    em.close();
}

85. StudentCouchDBDateTest#testDelete()

Project: Kundera
Source File: StudentCouchDBDateTest.java
View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBDate studentMax = em.find(StudentCouchDBDate.class, getMaxValue(Date.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBDate.class, getMaxValue(Date.class));
    Assert.assertNull(studentMax);
    em.close();
}

86. StudentCouchDBDoublePrimitiveTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBDoublePrimitive studentMax = em.find(StudentCouchDBDoublePrimitive.class, getMaxValue(Double.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBDoublePrimitive.class, getMaxValue(Double.class));
    Assert.assertNull(studentMax);
    em.close();
}

87. StudentCouchDBDoubleWrapperTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBDoubleWrapper studentMax = em.find(StudentCouchDBDoubleWrapper.class, getMaxValue(Double.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBDoubleWrapper.class, getMaxValue(Double.class));
    Assert.assertNull(studentMax);
    em.close();
}

88. StudentCouchDBFloatPrimitiveTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBFloatPrimitive studentMax = em.find(StudentCouchDBFloatPrimitive.class, getMaxValue(float.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBFloatPrimitive.class, getMaxValue(float.class));
    Assert.assertNull(studentMax);
    em.close();
}

89. StudentCouchDBFloatWrapperTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBFloatWrapper studentMax = em.find(StudentCouchDBFloatWrapper.class, getMaxValue(Float.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBFloatWrapper.class, getMaxValue(Float.class));
    Assert.assertNull(studentMax);
    em.close();
}

90. StudentCouchDBIntegerTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBInteger studentMax = em.find(StudentCouchDBInteger.class, getMaxValue(Integer.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBInteger.class, getMaxValue(Integer.class));
    Assert.assertNull(studentMax);
    em.close();
}

91. StudentCouchDBIntTest#testDelete()

Project: Kundera
Source File: StudentCouchDBIntTest.java
View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBInt studentMax = em.find(StudentCouchDBInt.class, getMaxValue(int.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBInt.class, getMaxValue(int.class));
    Assert.assertNull(studentMax);
    testPersist(useSameEm);
    em.close();
}

92. StudentCouchDBLongPrimitiveTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBLongPrimitive studentMax = em.find(StudentCouchDBLongPrimitive.class, getMaxValue(long.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBLongPrimitive.class, getMaxValue(long.class));
    Assert.assertNull(studentMax);
    em.close();
}

93. StudentCouchDBLongWrapperTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBLongWrapper studentMax = em.find(StudentCouchDBLongWrapper.class, getMaxValue(Long.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBLongWrapper.class, getMaxValue(Long.class));
    Assert.assertNull(studentMax);
    em.close();
}

94. StudentCouchDBShortPrimitiveTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBShortPrimitive studentMax = em.find(StudentCouchDBShortPrimitive.class, getMaxValue(Short.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBShortPrimitive.class, getMaxValue(Short.class));
    Assert.assertNull(studentMax);
    em.close();
}

95. StudentCouchDBShortWrapperTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBShortWrapper studentMax = em.find(StudentCouchDBShortWrapper.class, getMaxValue(Short.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBShortWrapper.class, getMaxValue(Short.class));
    Assert.assertNull(studentMax);
    em.close();
}

96. StudentCouchDBSqlDateTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBSqlDate studentMax = em.find(StudentCouchDBSqlDate.class, getMaxValue());
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBSqlDate.class, getMaxValue());
    Assert.assertNull(studentMax);
    em.close();
}

97. StudentCouchDBStringTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBString studentMax = em.find(StudentCouchDBString.class, getMaxValue(String.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBString.class, getMaxValue(String.class));
    Assert.assertNull(studentMax);
    em.close();
}

98. StudentCouchDBTimestampTest#testDelete()

View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBTimestamp studentMax = em.find(StudentCouchDBTimestamp.class, getMaxValue(Timestamp.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBTimestamp.class, getMaxValue(Timestamp.class));
    Assert.assertNull(studentMax);
    em.close();
}

99. StudentCouchDBTimeTest#testDelete()

Project: Kundera
Source File: StudentCouchDBTimeTest.java
View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBTime studentMax = em.find(StudentCouchDBTime.class, getMaxValue(Time.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBTime.class, getMaxValue(Time.class));
    Assert.assertNull(studentMax);
    em.close();
}

100. StudentCouchDBUUIDTest#testDelete()

Project: Kundera
Source File: StudentCouchDBUUIDTest.java
View license
public void testDelete(boolean useSameEm) {
    EntityManager em = emf.createEntityManager();
    StudentCouchDBUUID studentMax = em.find(StudentCouchDBUUID.class, getMaxValue(UUID.class));
    Assert.assertNotNull(studentMax);
    Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
    Assert.assertEquals("Kuldeep", studentMax.getName());
    em.remove(studentMax);
    if (!useSameEm) {
        em.close();
        em = emf.createEntityManager();
    }
    studentMax = em.find(StudentCouchDBUUID.class, getMaxValue(UUID.class));
    Assert.assertNull(studentMax);
    em.close();
}