List of usage examples for org.hibernate StatelessSession insert
Serializable insert(String entityName, Object entity);
From source file:edu.uncc.genosets.datamanager.persister.AnalysisSetPersister.java
License:Open Source License
@Override public void persist(StatelessSession session) { if (analysisSet.getId() == null) { session.insert(analysisSet.getDefaultName(), analysisSet); }/*w w w . j a v a 2 s . co m*/ for (CustomizableEntity entity : entities) { if (entity.getId() == null) { session.insert(entity.getDefaultName(), entity); } FactAnalysisSet fact = new FactAnalysisSet(); fact.setAnalysisSetId(analysisSet.getAnalysisSetId()); fact.setEntityId(entity.getId()); fact.setEntityTable(entity.getEntityName()); session.insert(fact.getDefaultName(), fact); } }
From source file:edu.uncc.genosets.datamanager.persister.EntityPersister.java
License:Open Source License
@Override public void persist(StatelessSession session) { if (entity.getId() == null) { session.insert(entityName, entity); } }
From source file:edu.uncc.genosets.studyset.StudySetPersister.java
License:Open Source License
@Override public void persist(StatelessSession ss) { if (studySet.getId() == null) { ss.insert(studySet.getEntityName(), studySet); } else {//from w w w . j a va 2s . c om ss.update(studySet.getEntityName(), studySet); } if (toAdd != null) { for (FactStudySet factStudySet : toAdd) { if (factStudySet.getFactId() == null) { factStudySet.setStudySetId(studySet.getId()); ss.insert(factStudySet.getEntityName(), factStudySet); } } } if (toDelete != null) { for (FactStudySet factStudySet : toDelete) { if (factStudySet.getFactId() != null) { ss.delete(factStudySet.getEntityName(), factStudySet); } } } }
From source file:org.openbravo.test.dal.DalPerformanceProxyTest.java
License:Open Source License
@Test public void testStatelessBPCreate() { try {// ww w . j a v a 2 s .c o m setTestAdminContext(); final StatelessSession session = SessionFactoryController.getInstance().getSessionFactory() .openStatelessSession(); session.beginTransaction(); for (int i = 0; i < CNT; i++) { BusinessPartner bp = OBProvider.getInstance().get(BusinessPartner.class); // Generating random strings for testing UUID name = UUID.randomUUID(); UUID key = UUID.randomUUID(); bp.setName(name.toString()); bp.setSearchKey(key.toString()); bp.setBusinessPartnerCategory(createReferencedObject(Category.class, TEST_BP_CATEGORY_ID)); // note the following things are currently done in the OBInterceptor // it is quite easy to add a util method which can do this in a generic // way for any business object bp.setOrganization(createReferencedObject(Organization.class, TEST_ORG_ID)); bp.setClient(createReferencedObject(Client.class, TEST_CLIENT_ID)); bp.setCreatedBy(createReferencedObject(User.class, "100")); bp.setCreationDate(new Date()); bp.setUpdatedBy(createReferencedObject(User.class, "100")); bp.setUpdated(new Date()); session.insert(BusinessPartner.ENTITY_NAME, bp); // session.refresh(BusinessPartner.ENTITY_NAME, bp); Assert.assertTrue(bp.getId() != null); } session.getTransaction().commit(); } catch (Exception e) { throw new OBException(e); } }