Package org.sf.bee.commons.persistence

Examples of org.sf.bee.commons.persistence.IEntity


            if (null == em
                    || null == entity
                    || !(entity instanceof IEntity)) {
                return null;
            }
            final IEntity ientity = (IEntity) entity;
            final long id = null != ientity.getId() ? ientity.getId() : 0L;
            T result = null;
            //-- merge entity --//
            if (id > 0L) {
                try {
                    result = em.merge(entity);
View Full Code Here


            if (null == em
                    || null == entity
                    || !(entity instanceof IEntity)) {
                return null;
            }
            final IEntity ientity = (IEntity) entity;
            final long id = null != ientity.getId() ? ientity.getId() : 0L;
            T result = null;
            //-- persist or merge entity --//
            if (id > 0L) {
                try {
                    em.refresh(entity);
View Full Code Here

    public <T extends Object> void saveEntity(final EntityManager em,
            final T entity) throws Exception {
        if (null != em
                && null != entity
                && (entity instanceof IEntity)) {
            final IEntity ientity = (IEntity) entity;
            this.persistNative(em, ientity);
        }
    }
View Full Code Here

    public <T extends Object> void removeEntity(final EntityManager em,
            final Class<T> entityClass, final T detached) throws Exception {
        //em.remove(detached);
        if (detached instanceof IEntity) {
            final IEntity ientity = (IEntity) detached;
            final long id = ientity.getId();
            this.removeDetachedEntity(em, entityClass, id);
        }
    }
View Full Code Here

                || null == entity
                || !(entity instanceof IEntity)) {
            return null;
        }
        if (this.beginTransaction(em)) {
            final IEntity ientity = (IEntity) entity;
            final long id = null != ientity.getId() ? ientity.getId() : 0L;
            final IEntity result;
            //-- persist or merge entity --//
            if (id == 0L) {
                // insert
                em.persist(entity);
                em.flush();
View Full Code Here

        return null;
    }

    private IEntity persistNativeWithChildren(final EntityManager em, final Object entity) throws Exception {
        if (entity instanceof IEntity) {
            final IEntity ientity = this.persistNative(em, (IEntity) entity);
            if (null != ientity) {
                final Object[] collections = BeanUtils.getReturnTypeValues(entity,
                        Collection.class);
                if (!CollectionUtils.isEmpty(collections)) {
                    for (final Object item : collections) {
View Full Code Here

TOP

Related Classes of org.sf.bee.commons.persistence.IEntity

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.