Package net.sf.hibernate

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


        return domainContext;
    }

    private Object getObject(int id, String type) throws Exception {
        Session session = getSession();
        return session.load(Class.forName(type), new Integer(id));
    }

    private void render(Object object, DomainContext context, boolean inclusive) throws IOException, JspException {

        JspWriter out = pageContext.getOut();
View Full Code Here


    private Object[] getObjects(Class fromDataClass, int id, String propertyName, Class toDataClass) throws Exception {
        try {
            Session session = ThreadSession.get();
            Class objectClass = getInternalClass(fromDataClass);
            log.debug("getting object: " + id);
            Object object = session.load(objectClass, new Integer(id));
            log.debug("loaded object: " + object);
            Collection objects = (Collection)PropertyUtils.getProperty(object, propertyName);
            Object[] dataArray = toArray(toDataClass, objects);
            return dataArray;
        } catch (Exception ex) {
View Full Code Here

        Session session = null;
        try {
            session = ThreadSession.get();
            Class objectClass = getInternalClass(dataClass);
            log.debug("getting object: " + id);
            DomainObject object = (DomainObject)session.load(objectClass, new Integer(id));
            log.debug("loaded object: " + object);
            DomainData data = (DomainData)dataClass.newInstance();
            if (hasPermission(getProjectId(object), object, "read")) {
                populateDomainData(data, object);
                return data;
View Full Code Here

        try {
            Integer id = NULL;
            session = ThreadSession.get();
            Class objectClass = getInternalClass(data.getClass());
            id = getObjectId(data);
            DomainObject object = (DomainObject)session.load(objectClass, id);
            if (hasPermission(getProjectId(object), object, "edit")) {
                // JM: no need to write lock the object
                // There is a lot more chance to get the client out-of-sync during a get/update than just in that method
                // See to-do at the top of the file for better implementation
                if (object != null) {
View Full Code Here

        Session session = null;
        try {
            session = ThreadSession.get();
            log.debug("removing object: " + id);
            Class objectClass = getInternalClass(dataClass);
            Object object = session.load(objectClass, new Integer(id));
            if (hasPermission(getProjectId(object), (DomainObject)object, "delete")) {
                session.delete(object);
                saveHistory(session, object, HistoricalEvent.DELETED);
                commit(session);
            } else {
View Full Code Here

    public String getAttribute(int targetId, String name) throws RepositoryException {
        try {
            final Session session = ThreadSession.get();
            final Attribute id = new Attribute(targetId, name, null);
            Attribute attribute = (Attribute)session.load(Attribute.class, id);
            return attribute.getValue();
        } catch (net.sf.hibernate.ObjectNotFoundException e) {
            return null;
        } catch (RuntimeException e) {
            throw e;
View Full Code Here

        List types = Arrays.asList(new Class[]{ Project.class, Iteration.class, UserStory.class, Task.class });
        for (int i = 0; i < types.size(); i++) {
            Class attacheeClass = (Class)types.get(i);
            Object object = null;
            try {
                object = session.load(attacheeClass, id);
            } catch (ObjectNotFoundException e) {
                // ignored
            }
            if (object != null) {
                target = object;
View Full Code Here

                }
            }
            Session session = getSession();
            try {
                Class clazz = Class.forName(type);
                Object object = session.load(clazz, objectId);
                pageContext.setAttribute(id, object, getScope());
                if (log.isDebugEnabled()) {
                    log.debug("bean loaded: " + id + " " + object);
                }
            } catch (Exception ex) {
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.