001: /*
002: * Copyright 2004,2005 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.wso2.esb.persistence.dao;
017:
018: import org.wso2.esb.persistence.dataobject.StatisticsDO;
019: import org.wso2.esb.util.HibernateConfig;
020:
021: import java.util.List;
022:
023: /**
024: *
025: *
026: */
027:
028: public class StatisticsDAO extends BaseDAO {
029:
030: public StatisticsDAO(HibernateConfig hbConfig) {
031: super (hbConfig);
032: }
033:
034: /**
035: * Add a Statistics Record
036: *
037: * @param statisticsDO
038: */
039: public void addStatisticsRecord(StatisticsDO statisticsDO) {
040: create(statisticsDO);
041: }
042:
043: /**
044: * Delete a Statistics Record
045: *
046: * @param statisticsDO
047: */
048: public void deleteStatisticsRecord(StatisticsDO statisticsDO) {
049: delete(statisticsDO);
050: }
051:
052: /**
053: * Update a Statistics Record
054: *
055: * @param statisticsDO
056: */
057: public void updateStatisticsRecord(StatisticsDO statisticsDO) {
058: update(statisticsDO);
059: }
060:
061: public int clearAll(String hqlQuery) {
062: return execute(hqlQuery);
063: }
064:
065: /**
066: * To Retrieves Statistics Records
067: *
068: * @param hqlQuery
069: * @return Statistics Records
070: */
071: public StatisticsDO[] selectStatisticsRecords(String hqlQuery) {
072: List list = select(hqlQuery);
073: StatisticsDO[] statisticsDOs = new StatisticsDO[list.size()];
074: if (!list.isEmpty()) {
075: list.toArray(statisticsDOs);
076: }
077: return statisticsDOs;
078: }
079:
080: /**
081: * To Retrieves Statistics Records using SQL
082: *
083: * @param sqlQuery
084: * @param aClass
085: * @return Statistics Records
086: */
087: public StatisticsDO[] selectStatisticsRecordsBySQL(String sqlQuery,
088: Class aClass) {
089: List list = selectBySQL(sqlQuery, aClass);
090: StatisticsDO[] statisticsDOs = new StatisticsDO[list.size()];
091: if (!list.isEmpty()) {
092: list.toArray(statisticsDOs);
093: }
094: return statisticsDOs;
095: }
096:
097: /**
098: * To create a new Object using statistics records
099: *
100: * @param hqlQuery
101: * @return A result as object
102: */
103: public Object createAnewObject(String hqlQuery) {
104: return selectUnique(hqlQuery);
105: }
106:
107: public List selectCustomObjectList(String hqlQuery) {
108: return select(hqlQuery);
109: }
110: }
|