Live Writer Test

测试下LiveWriter写CNblog:

1、Source code plug-in:

@Override

	public List getAll(String orgid,String start, String limit, String query1) {

		Query query = null;

		Session session = sessionFactory.openSession();

		try {

	        String sql = "select a.userid,a.username,a.gender,"

	        		+ "(select rolename from Role where roleid=(select roleid from TUser_Role where userid=a.userid)) as rolename, "

	        		+ "(select orgname from Organization where orgid=a.orgid) as orgname,"

	        		+ "(select departmentname from Department where departid=a.departid) as deparname,"

	        		+ "a.tel from TUser a where orgid='"+orgid+"'";

	        session.beginTransaction();

	        query = session.createQuery(sql);

	        query.setFirstResult(Integer.valueOf(start));

	        query.setMaxResults(Integer.valueOf(limit));

	        return query.list();

		} catch (Exception e) {

			e.printStackTrace();

			return null;

		} finally {

			session.close();

		}

	}
 
2、插入代码:
@Override

    public List getAll(String orgid,String start, String limit, String query1) {

        Query query = null;

        Session session = sessionFactory.openSession();

        try {

            String sql = "select a.userid,a.username,a.gender,"

                    + "(select rolename from Role where roleid=(select roleid from TUser_Role where userid=a.userid)) as rolename, "

                    + "(select orgname from Organization where orgid=a.orgid) as orgname,"

                    + "(select departmentname from Department where departid=a.departid) as deparname,"

                    + "a.tel from TUser a where orgid='"+orgid+"'";

            session.beginTransaction();

            query = session.createQuery(sql);

            query.setFirstResult(Integer.valueOf(start));

            query.setMaxResults(Integer.valueOf(limit));

            return query.list();

        } catch (Exception e) {

            e.printStackTrace();

            return null;

        } finally {

            session.close();

        }

    }

你可能感兴趣的:(Writer)