Package org.ow2.easybeans.tests.common.ejbs.entity.ebstore

Examples of org.ow2.easybeans.tests.common.ejbs.entity.ebstore.EBStore


     * @see org.ow2.easybeans.tests.common.ejbs.base.persistencectxlife.ItfPCtxLifetime00
     */
    @SuppressWarnings("boxing")
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void createCheckEntity00() {
        eb = new EBStore(id);
        em.persist(eb);

        assertTrue(em.contains(eb), "The entity instance should be managed.");

        EBStore ebFind = em.find(EBStore.class, id);

        assertTrue(ebFind == eb, "The entity instances should be equals, "
                + "they are in the same persistence context.");
    }
View Full Code Here


     * @see org.ow2.easybeans.tests.common.ejbs.base.persistencectxlife.ItfPCtxLifetime00
     */
    @SuppressWarnings("boxing")
    @TransactionAttribute(TransactionAttributeType.NEVER)
    public void createCheckEntity01() {
        eb = new EBStore(id);
        em.persist(eb);

        assertFalse(em.contains(eb), "The entity instance should be detached.");
    }
View Full Code Here

    @SuppressWarnings("boxing")
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void checkManaged() {
        assertTrue(em.contains(eb), "The entity instance should be managed.");

        EBStore ebFind = em.find(EBStore.class, id);

        assertTrue(ebFind == eb, "The entity instances should be equals, "
                + "they are in the same persistence context.");
    }
View Full Code Here

     * @see org.ow2.easybeans.tests.common.ejbs.base.persistencectxlife.ItfPCtxLifetime00
     */
    @SuppressWarnings("boxing")
    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public void removeEntity() {
        EBStore ebFind = em.find(EBStore.class, id);
        if (ebFind != null) {
            em.remove(ebFind);
        }
    }
View Full Code Here

     * @param id the primary key.
     * @param name the entity name.
     * @return a new entity with the values.
     */
    private EBStore createBean(final Integer id, final String name) {
        EBStore ebstore = new EBStore();
        ebstore.setId(id.intValue());
        ebstore.setName(name);
        return ebstore;
    }
View Full Code Here

    /**
     * Removes the beans of the database.
     *
     */
    private void removeEBStore(){
        EBStore ebstoreTransaction = entityManagerTransaction.find(EBStore.class, ID_TRANSACTION);
        if(ebstoreTransaction != null){
            entityManagerTransaction.remove(ebstoreTransaction);
        }

        EBStore ebstoreExtended = entityManagerExtended.find(EBStore.class, ID_EXTENDED);
        if(ebstoreExtended != null){
            entityManagerExtended.remove(ebstoreExtended);
        }

    }
View Full Code Here

     * Verifies if the bean created in transaction-scoped persistence context in
     * the startup method, and, a bean that was goten using the find method have
     * different reference.
     */
    public void testTransactionPersistenceContext() {
        EBStore ebstoreResult = entityManagerTransaction.find(EBStore.class, ID_TRANSACTION);
        assertFalse(ebstoreResult == ebstoreTransaction,
                "The entities were goten in diferents persistence context, so they should not have the same reference.");
    }
View Full Code Here

     * Verifies if the bean created in extended persistence context in the
     * startup method, and, a bean that was goten using the find method have the
     * same reference.
     */
    public void testExtendedPersistenceContext() {
        EBStore ebstoreResult = entityManagerExtended.find(EBStore.class, ID_EXTENDED);
        assertTrue(ebstoreResult == ebstoreExtended,
                "The entities were goten in the same persistence context, so they should have the same reference.");
    }
View Full Code Here

     * @param entityManager Entity Manager
     * @param name row name
     * @throws Exception if a problem occurs
     */
    public static void checkInstance(final EntityManager entityManager, final String name) throws Exception{
        EBStore store = new EBStore();
        store.setId(store.hashCode());
        store.setName(name);
        entityManager.persist(store);

        // flush only if there is a transaction
        UserTransaction utx = TransactionHelper.getInternalUserTransaction();
        if (utx != null) {
            if (utx.getStatus() == Status.STATUS_ACTIVE) {
                entityManager.flush();
            }
        }

        if (entityManager.find(EBStore.class, Integer.valueOf(store.hashCode())) == null){
            throw new Exception("EBStore was created, but it wasn't found after the commit.");
        }
    }
View Full Code Here

    /**
     * Deletes the bean with the default value.
     */
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void deleteBean() {
        EBStore ebstore = emDelete.find(EBStore.class, new Integer(ID));
        if (ebstore != null) {
            emDelete.remove(ebstore);
        }
        emDelete.flush();
    }
View Full Code Here

TOP

Related Classes of org.ow2.easybeans.tests.common.ejbs.entity.ebstore.EBStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.