コード例 #1
0
ファイル: Department.java プロジェクト: chengzhang-90/minioa
	public void selectRecordById(String id) {
		try {
			Query query = getSession().getNamedQuery("core.department.getrecordbyid");
			query.setParameter("id", id);
			Iterator<?> it = query.list().iterator();
			while (it.hasNext()) {
				this.reset();
				Object obj[] = (Object[]) it.next();
				if (obj[0] != null)
					ID_ = Integer.valueOf(String.valueOf(obj[0]));
				if (obj[1] != null)
					CID_ = Integer.valueOf(String.valueOf(obj[0]));
				if (obj[2] != null) {
					java.sql.Timestamp t = (java.sql.Timestamp) obj[2];
					CDATE_ = new java.util.Date(t.getTime());
					CDATE = dtf.format(CDATE_);
				}
				if (obj[3] != null)
					MID_ = Integer.valueOf(String.valueOf(obj[0]));
				if (obj[4] != null) {
					java.sql.Timestamp t = (java.sql.Timestamp) obj[4];
					MDATE_ = new java.util.Date(t.getTime());
					MDATE = dtf.format(MDATE_);
				}
				if (obj[5] != null)
					UUID_ = String.valueOf(obj[5]);
				if (obj[6] != null)
					orgId = Integer.valueOf(String.valueOf(obj[6]));
				if (obj[7] != null)
					parentId = Integer.valueOf(String.valueOf(obj[7]));
				if (obj[8] != null)
					depaName = String.valueOf(obj[8]);
				if (obj[9] != null)
					depaDesc = String.valueOf(obj[9]);
				if (obj[10] != null)
					sequence = Integer.valueOf(String.valueOf(obj[10]));
			}
			it = null;
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
コード例 #2
0
ファイル: Department.java プロジェクト: chengzhang-90/minioa
	/**
	 * 将全部记录加入列表
	 */
	public void buildRecordsList() {
		try {
			getMySession();
			recordsList = new ArrayList<Department>();
			Map<?, ?> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
			if ("false".equals((String) params.get("reload"))) {
				if (null != mySession.getTempInt() && mySession.getTempInt().containsKey("Department.rowcount")) {
					for (int i = 0; i < mySession.getTempInt().get("Department.rowcount"); i++)
						recordsList.add(new Department(i));
					return;
				}
			}

			Query query = getSession().getNamedQuery("core.department.records");
			Iterator<?> it = query.list().iterator();
			int id, cId, mId;
			String cDate, mDate, uuid;
			java.util.Date cDate_, mDate_;
			int org, parent, seq;
			String name, desc;
			int rowcount = 0;
			while (it.hasNext()) {
				Object obj[] = (Object[]) it.next();
				id = cId = mId = 0;
				cDate = mDate = uuid = "";
				cDate_ = mDate_ = null;
				org = parent = seq = 0;
				name = desc = "";
				// 读取obj数据时,一定要确保obj不能为null
				if (obj[0] != null)
					id = Integer.valueOf(String.valueOf(obj[0]));
				if (obj[1] != null)
					cId = Integer.valueOf(String.valueOf(obj[1]));
				if (obj[2] != null) {
					java.sql.Timestamp t = (java.sql.Timestamp) obj[2];
					cDate_ = new java.util.Date(t.getTime());
					cDate = dtf.format(cDate_);
				}
				if (obj[3] != null)
					mId = Integer.valueOf(String.valueOf(obj[3]));
				if (obj[4] != null) {
					java.sql.Timestamp t = (java.sql.Timestamp) obj[4];
					mDate_ = new java.util.Date(t.getTime());
					mDate = dtf.format(mDate_);
				}
				if (obj[5] != null)
					uuid = String.valueOf(obj[5]);
				if (obj[6] != null)
					org = Integer.valueOf(String.valueOf(obj[6]));
				if (obj[7] != null)
					parent = Integer.valueOf(String.valueOf(obj[7]));
				if (obj[8] != null)
					name = String.valueOf(obj[8]);
				if (obj[9] != null)
					desc = String.valueOf(obj[9]);
				if (obj[10] != null)
					seq = Integer.valueOf(String.valueOf(obj[10]));
				recordsList.add(new Department(id, cId, cDate, mId, mDate, uuid, org, parent, name, desc, seq));
				rowcount++;
			}
			it = null;

			mySession.getTempInt().put("Department.rowcount", rowcount);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}