Search in sources :

Example 16 with EntityManager

use of javax.persistence.EntityManager in project che by eclipse.

the class JpaFactoryDao method doUpdate.

@Transactional
protected FactoryImpl doUpdate(FactoryImpl update) throws NotFoundException {
    final EntityManager manager = managerProvider.get();
    if (manager.find(FactoryImpl.class, update.getId()) == null) {
        throw new NotFoundException(format("Could not update factory with id %s because it doesn't exist", update.getId()));
    }
    if (update.getWorkspace() != null) {
        update.getWorkspace().getProjects().forEach(ProjectConfigImpl::prePersistAttributes);
    }
    FactoryImpl merged = manager.merge(update);
    manager.flush();
    return merged;
}
Also used : EntityManager(javax.persistence.EntityManager) NotFoundException(org.eclipse.che.api.core.NotFoundException) FactoryImpl(org.eclipse.che.api.factory.server.model.impl.FactoryImpl) ProjectConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl) Transactional(com.google.inject.persist.Transactional)

Example 17 with EntityManager

use of javax.persistence.EntityManager in project che by eclipse.

the class JpaFactoryDao method doRemove.

@Transactional
protected void doRemove(String id) {
    final EntityManager manager = managerProvider.get();
    final FactoryImpl factory = manager.find(FactoryImpl.class, id);
    if (factory != null) {
        manager.remove(factory);
        manager.flush();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) FactoryImpl(org.eclipse.che.api.factory.server.model.impl.FactoryImpl) Transactional(com.google.inject.persist.Transactional)

Example 18 with EntityManager

use of javax.persistence.EntityManager in project che by eclipse.

the class JpaPreferenceDao method doRemove.

@Transactional
protected void doRemove(String userId) {
    final EntityManager manager = managerProvider.get();
    final PreferenceEntity prefs = manager.find(PreferenceEntity.class, userId);
    if (prefs != null) {
        manager.remove(prefs);
        manager.flush();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) Transactional(com.google.inject.persist.Transactional)

Example 19 with EntityManager

use of javax.persistence.EntityManager in project che by eclipse.

the class JpaProfileDao method doRemove.

@Transactional
protected void doRemove(String userId) {
    final EntityManager manager = managerProvider.get();
    final ProfileImpl profile = manager.find(ProfileImpl.class, userId);
    if (profile != null) {
        manager.remove(profile);
        manager.flush();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl) Transactional(com.google.inject.persist.Transactional)

Example 20 with EntityManager

use of javax.persistence.EntityManager in project che by eclipse.

the class JpaProfileDao method doUpdate.

@Transactional
protected void doUpdate(ProfileImpl profile) throws NotFoundException {
    final EntityManager manager = managerProvider.get();
    if (manager.find(ProfileImpl.class, profile.getUserId()) == null) {
        throw new NotFoundException(format("Couldn't update profile, because profile for user with id '%s' doesn't exist", profile.getUserId()));
    }
    manager.merge(profile);
    manager.flush();
}
Also used : EntityManager(javax.persistence.EntityManager) ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl) NotFoundException(org.eclipse.che.api.core.NotFoundException) Transactional(com.google.inject.persist.Transactional)

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