Package net.sf.hibernate

Examples of net.sf.hibernate.Session.save()


            if (UPDATE_OPERATION == operation) {
                session.update(obj);
            } else if (DELETE_OPERATION == operation) {
                session.delete(obj);
            } else if (SAVE_OPERATION == operation) {
                session.save(obj);
            }
            session.flush();
            session.evict(obj);
            tx.commit();
            session.close();
View Full Code Here


        if (dirs.iterator().hasNext()) {
            return (Directory)dirs.iterator().next();
        } else {
            Directory root = new Directory();
            root.setName("");
            session.save(root);
            session.flush();
            session.refresh(root);
            return root;
        }
    }
View Full Code Here

            Class objectClass = getInternalClass(data.getClass());
            DomainObject object = (DomainObject)objectClass.newInstance();
            if (hasPermission(projectId, object, "create")) {
                populateDomainObject(object, data);
                log.debug("adding object: " + object);
                Serializable id = session.save(object);
                saveHistory(session, object, HistoricalEvent.CREATED);
                commit(session);
                return getObject(data.getClass(), ((Integer)id).intValue());
            } else {
                throw new AuthenticationException("no permission to create object");
View Full Code Here

            List existingAttributes = session.find("from a in "+Attribute.class+
                    " where targetId = ? and name= ?",
                    new Object[]{ new Integer(targetId), name },
                    new Type[]{ Hibernate.INTEGER, Hibernate.STRING });
            if (existingAttributes.size() == 0) {
                session.save(attribute);
            } else {
                session.update(attribute);
            }
        } catch (RuntimeException e) {
            throw e;
View Full Code Here

                Date now = new Date();
                for (int i = 0; i < iterations.size(); i++) {
                    Iteration iteration = (Iteration)iterations.get(i);
                    DataSample estimatedHoursSample = new DataSample(now, iteration.getId(),
                            "estimatedHours", iteration.getEstimatedHours());
                    session.save(estimatedHoursSample);
                    DataSample actualHoursSample = new DataSample(now, iteration.getId(),
                            "actualHours", iteration.getActualHours());
                    session.save(actualHoursSample);
                    DataSample remainingHoursSample = new DataSample(now, iteration.getId(),
                            "remainingHours", iteration.getRemainingHours());
View Full Code Here

                    DataSample estimatedHoursSample = new DataSample(now, iteration.getId(),
                            "estimatedHours", iteration.getEstimatedHours());
                    session.save(estimatedHoursSample);
                    DataSample actualHoursSample = new DataSample(now, iteration.getId(),
                            "actualHours", iteration.getActualHours());
                    session.save(actualHoursSample);
                    DataSample remainingHoursSample = new DataSample(now, iteration.getId(),
                            "remainingHours", iteration.getRemainingHours());
                    session.save(remainingHoursSample);
                }
                log.info("committing data sample changes");
View Full Code Here

                    DataSample actualHoursSample = new DataSample(now, iteration.getId(),
                            "actualHours", iteration.getActualHours());
                    session.save(actualHoursSample);
                    DataSample remainingHoursSample = new DataSample(now, iteration.getId(),
                            "remainingHours", iteration.getRemainingHours());
                    session.save(remainingHoursSample);
                }
                log.info("committing data sample changes");
                session.flush();
                session.connection().commit();
            } catch (Throwable ex) {
View Full Code Here

        int projectId = 11;
        person = new Person("permissionTester");
        person.setName("permissionTester");
        person.setInitials("pt");
        int personId = ((Integer)session.save(person)).intValue();
        session.save(new RoleAssociation(projectId, personId, getRoleId(session, "admin")));
        addPermission(session, personId, "system.project", 1, "testpermission");

        session.flush();
        session.connection().commit();
View Full Code Here

        int projectId = 11;
        person = new Person("permissionTester");
        person.setName("permissionTester");
        person.setInitials("pt");
        int personId = ((Integer)session.save(person)).intValue();
        session.save(new RoleAssociation(projectId, personId, getRoleId(session, "admin")));
        addPermission(session, personId, "system.project", 1, "testpermission");

        session.flush();
        session.connection().commit();
View Full Code Here

                                        AbstractEditorForm form,
                                        ObjectRepository objectRepository) throws Exception
    {
        Session session = ThreadSession.get();
        DomainObject person = super.createObject(objectClass, request, form, objectRepository);
        session.save(new Permission("system.person",person.getId(),person.getId(),"edit%"));
        session.save(new Permission("system.person",0,person.getId(),"read%"));

        return person;
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.