Package net.sf.hibernate

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


            if (orderBy != null) {
                query += " order by " + orderBy;
            }
            List objects = values != null
                    ? session.find(query, values, types)
                    : session.find(query);
            return toArray(dataClass, objects);
        } catch (Exception ex) {
            log.error("error loading objects", ex);
            throw ex;
        }
View Full Code Here


public class AttributeRepositoryImpl implements AttributeRepository {
    public void setAttribute(int targetId, String name, String value) throws RepositoryException {
        try {
            final Session session = ThreadSession.get();
            final Attribute attribute = new Attribute(targetId, name, value);
            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);
View Full Code Here

    public Map getAttributes(int targetId, String prefix) throws RepositoryException {
        HashMap attributes = new HashMap();
        try {
            final Session session = ThreadSession.get();
            String pattern = (prefix != null ? prefix : "")+"%";
            List attributeObjects = session.find("from a in "+Attribute.class+
                    " where targetId = ? and name like ?",
                    new Object[]{ new Integer(targetId), pattern },
                    new Type[]{ Hibernate.INTEGER, Hibernate.STRING });
            for (int i = 0; i < attributeObjects.size(); i++) {
                Attribute attribute = (Attribute)attributeObjects.get(i);
View Full Code Here

    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try {
            Session session = null;
            try {
                session = GlobalSessionFactory.get().openSession();
                List iterations = session.find("from i in " + Iteration.class +
                        " where i.endDate >= ?", new Date(), Hibernate.DATE);
                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(),
View Full Code Here

                int principalId = getPrincipalId();
                session = getSession();
                skipBody = checkPermission(session, projectId, principalId);
                if (skipBody == true && projectId == 0) {
                    // Has permission for any...
                    Collection projects = session.find("from project in "+Project.class);
                    for (Iterator iterator = projects.iterator(); iterator.hasNext();) {
                        Project project = (Project)iterator.next();
                        skipBody = checkPermission(session, project.getId(), principalId);
                        if (!skipBody) {
                            break;
View Full Code Here

    public void run(String[] args) {
        try {
            HibernateHelper.initializeHibernate();
            Session session = GlobalSessionFactory.get().openSession();
            List projects = session.find("from project in "+Project.class+" where project.hidden = false");
            try {
                if (isOldRoleTableExisting()) {
                    upgradeRoles(session, projects);
                    dropTable(session, "personrole");
                }
View Full Code Here

        return "@test." + baseName + "." + System.currentTimeMillis() + "@";
    }

    protected void setUpRole(Person person, Project project, String roleName) throws HibernateException {
        Session session = tester.getSession();
        List roles = session.find("from role in class " + Role.class.getName() +
                " where role.name = ?", roleName, Hibernate.STRING);
        Role role = null;
        if (roles.size() > 0) {
            role = (Role) roles.get(0);
        } else {
View Full Code Here

        AggregateTimesheetForm form = (AggregateTimesheetForm)actionForm;
        try {
            Session session = getSession(request);
            try {

                form.setAllPeople(session.find("from people in class org.nxplanner.domain.Person " +
                        "where people.hidden = false order by name"));
                AggregateTimesheetQuery query = new AggregateTimesheetQuery(getSession(request));
                query.setPersonIds(form.getSelectedPeople());
                query.setStartDate(form.getStartDate());
                query.setEndDate(form.getEndDate());
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.