Example usage for org.hibernate SQLQuery addEntity

List of usage examples for org.hibernate SQLQuery addEntity

Introduction

In this page you can find the example usage for org.hibernate SQLQuery addEntity.

Prototype

SQLQuery<T> addEntity(Class entityType);

Source Link

Document

Declare a "root" entity, without specifying an alias.

Usage

From source file:com.waveerp.systemSessFunc.java

License:Open Source License

public String updateSession(String pJuid) {

    String strResult = "OK";

    //Execute the SQL script using this object
    execGenericNonQuery enq = new execGenericNonQuery();
    //For the SQL Escape
    systemTextUtils stu = new systemTextUtils();

    List<Tblsessions> myList = null;
    Iterator<Tblsessions> iterator = null;
    Tblsessions sess = null;//from   w w w .  ja va 2  s .  com

    //Get the current time of the system
    java.util.Date dnow = new java.util.Date();
    Timestamp now = new Timestamp(dnow.getTime());
    Timestamp lastTime = new Timestamp(dnow.getTime());
    long duration = 0;
    long tdiff = 0;

    try {

        dbServices.begin();

        Session session = dbServices.getDataServiceManager().getSession();
        String sQuery = "select * from Tblsessions where juid = '" + pJuid + "' ;";

        SQLQuery query = session.createSQLQuery(sQuery);
        query.addEntity(Tblsessions.class);

        myList = query.list();

        dbServices.commit();

        iterator = myList.iterator();

        /**
        * At this point, only one record should be retrieved
        */
        while (iterator.hasNext()) {

            sess = (Tblsessions) iterator.next();

        }

    } catch (Exception e) {

        dbServices.rollback();
        strResult = "FAIL";

    }

    // Get all possible values from the selection
    if (sess != null) {

        lastTime = (Timestamp) sess.getTimemodify();
        duration = (int) sess.getTimetolive();

        tdiff = now.getTime() - lastTime.getTime();

        strResult = tdiff + "";

        //Check if this session is expired already
        if (tdiff <= duration) {

            // Update the object
            if (sess != null) {

                sess.setTimemodify(now);
                sess.setTimeleft((int) duration);

            }

            //Update the session here
            try {

                //dbServices.begin();
                //    dbServices.update(sess);
                //dbServices.commit();

                String sQL = "";
                sQL = sQL + "update Tblsessions set ";
                sQL = sQL + "timemodify = " + stu.mySQLEscape(now.toString()) + ", ";
                sQL = sQL + "timeleft = " + stu.mySQLEscape(strResult) + " ";

                sQL = sQL + "where juid = '" + stu.mySQLEscape(pJuid) + "' ;";

                enq.execNonQuery(sQL);

                strResult = "OK";

            } catch (Exception e) {

                return "FAIL"; //e.getMessage();

            }

        } else {

            //Expired session because it
            //exceeds its duration or time to live.
            deleteSession(pJuid);

            strResult = "EXPIRE";

        } //if(tdiff <= duration)

    } else {

        //Cannot find the session, then assumed
        //that it had expired already.
        strResult = "EXPIRE";

    } //if( sess != null )               

    return strResult;

}

From source file:com.waveerp.systemSessFunc.java

License:Open Source License

public int countSession(String pEntityId) {

    String strResult = "OK";
    int iCount = 0;

    List<Tblsessions> myList = null;
    Iterator<Tblsessions> iterator = null;
    Tblsessions sess = null;//from  w  w  w .  jav a 2  s .co  m

    try {

        dbServices.begin();

        Session session = dbServices.getDataServiceManager().getSession();
        String sQuery = "select * from Tblsessions where entityid = '" + pEntityId + "' ;";

        SQLQuery query = session.createSQLQuery(sQuery);
        query.addEntity(Tblsessions.class);

        myList = query.list();

        dbServices.commit();

        iterator = myList.iterator();

        while (iterator.hasNext()) {

            sess = (Tblsessions) iterator.next();
            iCount++;

        }

    } catch (Exception e) {

        dbServices.rollback();
        return 0;

    }

    return iCount;

}

From source file:com.waveerp.systemSessFunc.java

License:Open Source License

public String deleteExpiredSession(String pEntityId) {

    String strResult = "OK";

    List<Tblsessions> myList = null;
    Iterator<Tblsessions> iterator = null;
    Tblsessions sess = null;//from   www .j  a va  2s . c om

    //Get the current time of the system
    java.util.Date dnow = new java.util.Date();
    Timestamp now = new Timestamp(dnow.getTime());
    Timestamp lastTime = new Timestamp(dnow.getTime());
    long duration = 0;
    long tdiff = 0;

    try {

        dbServices.begin();

        Session session = dbServices.getDataServiceManager().getSession();
        String sQuery = "select * from Tblsessions where entityid = '" + pEntityId + "' ;";

        SQLQuery query = session.createSQLQuery(sQuery);
        query.addEntity(Tblsessions.class);

        myList = query.list();

        dbServices.commit();

        iterator = myList.iterator();

        /**
        * At this point, only one record should be retrieved
        */
        while (iterator.hasNext()) {

            sess = (Tblsessions) iterator.next();

            String strJuid = (String) sess.getJuid();

            lastTime = (Timestamp) sess.getTimemodify();
            duration = (int) sess.getTimetolive();

            tdiff = now.getTime() - lastTime.getTime();

            //Expired Sessions
            if (tdiff > duration) {

                deleteSession(strJuid);

            } else {

                //Just update the time left
                timeleftSession(strJuid, duration - tdiff);

            }

        }

    } catch (Exception e) {

        dbServices.rollback();
        return "FAIL";

    }

    return strResult;

}

From source file:com.waveerp.systemUserFunc.java

License:Open Source License

public String copyRoleRights(String pSrcRole, String pDstRole, String pEntityId) {

    String strJuid = "FAIL";

    List<Tblrightasgn> myList = null;
    Iterator<Tblrightasgn> iterator = null;

    try {//from w w  w. ja v a2 s  . c o  m
        dbServices.begin();

        Session session = dbServices.getDataServiceManager().getSession();
        String sQuery = "select * from Tblrightasgn where entityid = '" + pEntityId + "' and roleid = '"
                + pSrcRole + "' ;";

        SQLQuery query = session.createSQLQuery(sQuery);
        query.addEntity(Tblrightasgn.class);

        myList = query.list();

        dbServices.commit();

        iterator = myList.iterator();

        String strEntityId = "";
        String strRightId = "";
        String strRoleId = "";
        String strAppId = "";
        String strStatus = "";
        String strDesc = "";

        while (iterator.hasNext()) {

            Tblrightasgn rightsAsgn = (Tblrightasgn) iterator.next();

            strJuid = (String) rightsAsgn.getJuid();
            strEntityId = (String) rightsAsgn.getEntityid();
            strRightId = (String) rightsAsgn.getRightid();
            strRoleId = (String) rightsAsgn.getRoleid();
            strAppId = (String) rightsAsgn.getAppid();
            strStatus = (String) rightsAsgn.getSstatus();
            strDesc = (String) rightsAsgn.getDescription();

            //Create a new right
            Tblrightasgn addEntry = new Tblrightasgn();

            Date date = new Date();
            UUID guid = UUID.randomUUID();

            addEntry.setJuid(guid.toString());
            addEntry.setEntityid(pEntityId);
            addEntry.setRightid(strRightId);
            addEntry.setRoleid(pDstRole);
            addEntry.setAppid(strAppId);
            addEntry.setSstatus(strStatus);
            addEntry.setDescription(strDesc);

            dbServices.insert(addEntry);
            dbServices.commit();

        }

    } catch (Exception e) {

        dbServices.rollback();
        return "FAIL";

    }

    return "OK";

}

From source file:com.waveerp.systemUserFunc.java

License:Open Source License

public String updateParty(String pJuid, String pEntityId, String pPartyId, String pTitle, String pFirstName,
        String pMiddleName, String pLastName, String pSuffix, String pAddr01, String pAddr02, String pCity,
        String pEmpState, String pZipCode, String pCountry, String pEmail, String pCountryCodeHome,
        String pAreaCodeHome, String pPhoneHome, String pExtensionHome, String pCountryCodeWork,
        String pAreaCodeWork, String pPhoneWork, String pExtensionWork, String pCountryCodeMobile,
        String pAreaCodeMobile, String pPhoneMobile, String pExtensionMobile, String pCountryCodeFax,
        String pAreaCodeFax, String pPhoneFax, String pExtensionFax, String pRoleType, String pUserJuid,
        String pStatus, String pPid

) {/*from  ww  w .ja  v a  2 s  . c  om*/

    //Execute the SQL script using this object
    execGenericNonQuery enq = new execGenericNonQuery();
    //For the SQL Escape
    systemTextUtils stu = new systemTextUtils();

    String retVal = "OK";

    List<Tblperson> myList = null;
    Iterator<Tblperson> iterator = null;
    Tblperson tblPerson = null;

    try {
        dbServices.begin();

        Session session = dbServices.getDataServiceManager().getSession();
        String sQuery = "select * from Tblperson where juid = '" + pJuid + "'";

        SQLQuery query = session.createSQLQuery(sQuery);
        query.addEntity(Tblperson.class);
        myList = query.list();

        dbServices.commit();

        iterator = myList.iterator();

        /**
         * At this point, only one record should be retrieved
        */
        while (iterator.hasNext()) {

            tblPerson = (Tblperson) iterator.next();

        }

    } catch (Exception e) {

        dbServices.rollback();
        return e.getMessage(); //"FAIL";

    }

    // Update the object
    if (tblPerson == null) {

        //Do nothing for NULL
        retVal = "NULL";

    } else {

        //Do the update now.  
        try {

            if (pTitle == null) {
                pTitle = "";
            }
            if (pFirstName == null) {
                pFirstName = "";
            }
            if (pMiddleName == null) {
                pMiddleName = "";
            }
            if (pLastName == null) {
                pLastName = "";
            }
            if (pSuffix == null) {
                pSuffix = "";
            }
            if (pAddr01 == null) {
                pAddr01 = "";
            }
            if (pAddr02 == null) {
                pAddr02 = "";
            }
            if (pCity == null) {
                pCity = "";
            }
            if (pEmpState == null) {
                pEmpState = "";
            }
            if (pZipCode == null) {
                pZipCode = "";
            }
            if (pCountry == null) {
                pCountry = "";
            }
            if (pEmail == null) {
                pEmail = "";
            }

            //tblPerson.setJuid( pJuid );  
            //tblPerson.setEntityid( pEntityId );
            //tblPerson.setPartyid( pPartyId );
            tblPerson.setTitle(pTitle);
            tblPerson.setFirstname(pFirstName);
            tblPerson.setMiddlename(pMiddleName);
            tblPerson.setLastname(pLastName);
            tblPerson.setSuffix(pSuffix);
            tblPerson.setAddr01(pAddr01);
            tblPerson.setAddr02(pAddr02);
            tblPerson.setCity(pCity);
            tblPerson.setEmpstate(pEmpState);
            tblPerson.setZipcode(pZipCode);
            tblPerson.setCountry(pCountry);
            tblPerson.setEmail(pEmail);

            tblPerson.setCountrycodehome(pCountryCodeHome);
            tblPerson.setAreacodehome(pAreaCodeHome);
            tblPerson.setPhonehome(pPhoneHome);
            tblPerson.setExtensionhome(pExtensionHome);

            tblPerson.setCountrycodework(pCountryCodeWork);
            tblPerson.setAreacodework(pAreaCodeWork);
            tblPerson.setPhonework(pPhoneWork);
            tblPerson.setExtensionwork(pExtensionWork);

            tblPerson.setCountrycodefax(pCountryCodeFax);
            tblPerson.setAreacodefax(pAreaCodeFax);
            tblPerson.setPhonefax(pPhoneFax);
            tblPerson.setExtensionfax(pExtensionFax);

            tblPerson.setCountrycodemobile(pCountryCodeMobile);
            tblPerson.setAreacodemobile(pAreaCodeMobile);
            tblPerson.setPhonemobile(pPhoneMobile);
            tblPerson.setExtensionmobile(pExtensionMobile);

            tblPerson.setRoletype(pRoleType);
            tblPerson.setUserjuid(pUserJuid);
            tblPerson.setSstatus(pStatus);
            tblPerson.setPid(pPid);
            //tblPerson.setDeleted( 0 );

            //dbServices.begin();

            //    dbServices.update(tblPerson);

            //dbServices.commit();

            //updatePerson( tblPerson );

            String sQL = "";
            sQL = sQL + "update tblperson set ";
            sQL = sQL + "title = '" + stu.mySQLEscape(pTitle) + "', ";
            sQL = sQL + "firstname = '" + stu.mySQLEscape(pFirstName) + "', ";
            sQL = sQL + "middlename = '" + stu.mySQLEscape(pMiddleName) + "', ";
            sQL = sQL + "lastname = '" + stu.mySQLEscape(pLastName) + "', ";
            sQL = sQL + "suffix = '" + stu.mySQLEscape(pSuffix) + "', ";
            sQL = sQL + "addr01 = '" + stu.mySQLEscape(pAddr01) + "', ";
            sQL = sQL + "addr02 = '" + stu.mySQLEscape(pAddr02) + "', ";
            sQL = sQL + "city = '" + stu.mySQLEscape(pCity) + "', ";
            sQL = sQL + "empstate = '" + stu.mySQLEscape(pEmpState) + "', ";
            sQL = sQL + "zipcode = '" + stu.mySQLEscape(pZipCode) + "', ";
            sQL = sQL + "country = '" + stu.mySQLEscape(pCountry) + "', ";
            sQL = sQL + "email = '" + stu.mySQLEscape(pEmail) + "', ";

            sQL = sQL + "countrycodehome = '" + stu.mySQLEscape(pCountryCodeHome) + "', ";
            sQL = sQL + "areacodehome = '" + stu.mySQLEscape(pAreaCodeHome) + "', ";
            sQL = sQL + "phonehome = '" + stu.mySQLEscape(pPhoneHome) + "', ";
            sQL = sQL + "extensionhome = '" + stu.mySQLEscape(pExtensionHome) + "', ";

            sQL = sQL + "countrycodework = '" + stu.mySQLEscape(pCountryCodeWork) + "', ";
            sQL = sQL + "areacodework = '" + stu.mySQLEscape(pAreaCodeWork) + "', ";
            sQL = sQL + "phonework = '" + stu.mySQLEscape(pPhoneWork) + "', ";
            sQL = sQL + "extensionwork = '" + stu.mySQLEscape(pExtensionWork) + "', ";

            sQL = sQL + "countrycodefax = '" + stu.mySQLEscape(pCountryCodeFax) + "', ";
            sQL = sQL + "areacodefax = '" + stu.mySQLEscape(pAreaCodeFax) + "', ";
            sQL = sQL + "phonefax = '" + stu.mySQLEscape(pPhoneFax) + "', ";
            sQL = sQL + "extensionfax = '" + stu.mySQLEscape(pExtensionFax) + "', ";

            sQL = sQL + "countrycodemobile = '" + stu.mySQLEscape(pCountryCodeMobile) + "', ";
            sQL = sQL + "areacodemobile = '" + stu.mySQLEscape(pAreaCodeMobile) + "', ";
            sQL = sQL + "phonemobile = '" + stu.mySQLEscape(pPhoneMobile) + "', ";
            sQL = sQL + "extensionmobile = '" + stu.mySQLEscape(pExtensionMobile) + "', ";

            sQL = sQL + "roletype = '" + stu.mySQLEscape(pRoleType) + "', ";
            sQL = sQL + "userjuid = '" + stu.mySQLEscape(pUserJuid) + "', ";
            sQL = sQL + "sstatus = '" + stu.mySQLEscape(pStatus) + "', ";

            sQL = sQL + "pid = '" + stu.mySQLEscape(pPid) + "' ";
            sQL = sQL + "where juid = '" + stu.mySQLEscape(pJuid) + "' ;";

            enq.execNonQuery(sQL);

        } catch (Exception e) {

            return e.getMessage();

        }

    }

    return retVal;
}

From source file:com.waveerp.systemUserFunc.java

License:Open Source License

public String createEmployeeExt(String pJuid, String pEntityId, String pParent, String pBadgeId,
        String pDivisionId, String pDivisionDesc, String pDepartmentId, String pDepartmentDesc,
        String pSectionId, String pSectionDesc, String pLocationId, String pLocationDesc, String pRestDayId,
        String pRestDayDesc, String pShiftId, String pShiftDesc, String pManagerId, String pManagerDesc,
        String pDeviceIn, String pDeviceOut, String pStatus) {

    List<Tblemployeeext> myList = null;
    Iterator<Tblemployeeext> iterator = null;
    Tblemployeeext tblEmployeeX = null;//w w w. ja  v a2  s.  co  m

    try {
        dbServices.begin();

        Session session = dbServices.getDataServiceManager().getSession();
        String sQuery = "select * from Tblemployeeext where parentPerson = '" + pParent + "' ;";

        SQLQuery query = session.createSQLQuery(sQuery);
        query.addEntity(Tblemployeeext.class);

        myList = query.list();

        dbServices.commit();

        iterator = myList.iterator();

        /**
         * At this point, only one record should be retrieved
        */
        while (iterator.hasNext()) {

            tblEmployeeX = (Tblemployeeext) iterator.next();

        }

    } catch (Exception e) {

        dbServices.rollback();
        return "FAIL";

    }

    String strJuid = "";

    // Update the object
    if (tblEmployeeX == null) {

        try {

            dbServices.begin();

            //Prepare data for insertion
            Tblemployeeext addEntry = new Tblemployeeext();
            UUID guid = UUID.randomUUID();
            strJuid = guid.toString();

            addEntry.setJuid(guid.toString());
            addEntry.setEntityid(pEntityId);
            addEntry.setParentPerson(pParent);
            addEntry.setBadgeid(pBadgeId);

            addEntry.setDivisionid(pDivisionId);
            addEntry.setDivisiondesc(pDivisionDesc);
            addEntry.setDepartmentid(pDepartmentId);
            addEntry.setDepartmentdesc(pDepartmentDesc);
            addEntry.setSectionid(pSectionId);
            addEntry.setSectiondesc(pSectionDesc);
            addEntry.setLocationid(pLocationId);
            addEntry.setLocationdesc(pLocationDesc);
            addEntry.setRestdayid(pRestDayId);
            addEntry.setRestdaydesc(pRestDayDesc);
            addEntry.setShiftid(pShiftId);
            addEntry.setShiftdesc(pShiftDesc);
            addEntry.setManagerid(pManagerId);
            addEntry.setManagerdesc(pManagerDesc);
            addEntry.setDevicein(pDeviceIn);
            addEntry.setDeviceout(pDeviceOut);
            addEntry.setSstatus(pStatus);

            dbServices.insert(addEntry);
            dbServices.commit();

        } catch (Exception e) {

            dbServices.rollback();
            return "FAIL";

        }

    } else {

        //Just update the object here
        tblEmployeeX.setEntityid(pEntityId);
        //tblEmployeeX.setParentPerson( pParent );
        tblEmployeeX.setBadgeid(pBadgeId);

        tblEmployeeX.setDivisionid(pDivisionId);
        tblEmployeeX.setDivisiondesc(pDivisionDesc);
        tblEmployeeX.setDepartmentid(pDepartmentId);
        tblEmployeeX.setDepartmentdesc(pDepartmentDesc);
        tblEmployeeX.setSectionid(pSectionId);
        tblEmployeeX.setSectiondesc(pSectionDesc);
        tblEmployeeX.setLocationid(pLocationId);
        tblEmployeeX.setLocationdesc(pLocationDesc);
        tblEmployeeX.setRestdayid(pRestDayId);
        tblEmployeeX.setRestdaydesc(pRestDayDesc);
        tblEmployeeX.setShiftid(pShiftId);
        tblEmployeeX.setShiftdesc(pShiftDesc);
        tblEmployeeX.setManagerid(pManagerId);
        tblEmployeeX.setManagerdesc(pManagerDesc);
        tblEmployeeX.setDevicein(pDeviceIn);
        tblEmployeeX.setDeviceout(pDeviceOut);
        tblEmployeeX.setSstatus(pStatus);

        //Do the update now.  
        try {

            dbServices.begin();
            dbServices.update(tblEmployeeX);
            dbServices.commit();

        } catch (Exception e) {

            return e.getMessage();

        }

    }

    return strJuid;

}

From source file:com.waveerp.systemUserFunc.java

License:Open Source License

public String createUser(String pJuid, String pEntityId, String pUserId, String pPassword, String pUsername,
        String pFirstname, String pMiddlename, String pLastname, String pStatus, String pEmail, String pRoleId,
        Date pStartDate, Date pEndDate, String pPid

) {/*from   ww w.j  a va  2 s  .c o m*/

    // Call the encryption management system
    desEncryption de = new desEncryption();
    de.Encrypter("", "");

    List<Tbluser> myList = null;
    Iterator<Tbluser> iterator = null;
    Tbluser item = null;

    try {

        dbServices.begin();

        Session session = dbServices.getDataServiceManager().getSession();
        String sQuery = "select * from Tbluser where userid = '" + pUserId + "' ;";

        SQLQuery query = session.createSQLQuery(sQuery);
        query.addEntity(Tbluser.class);
        myList = query.list();

        dbServices.commit();

        iterator = myList.iterator();

        // Loop and generate an encrypted password
        while (iterator.hasNext()) {

            item = (Tbluser) iterator.next();

        }

    } catch (Exception e) {

        dbServices.rollback();
        return "FAIL";

    }

    String strJuid = "";
    // Update the object
    if (item == null) {

        try {

            dbServices.begin();

            //Prepare data for insertion
            Tbluser addEntry = new Tbluser();

            UUID guid = UUID.randomUUID();
            strJuid = guid.toString();
            TbluserId newid = new TbluserId();
            newid.setJuid(guid.toString());
            newid.setSeqid(0);

            addEntry.setId(newid);

            addEntry.setUserid(pUserId);
            addEntry.setEntityid(pEntityId);

            // Return the key to be encoded
            addEntry.setPassword("LOCKED!");
            String strEnc = de.encrypt(pPassword);
            addEntry.setPasswdenc(strEnc);

            addEntry.setUsername(pUsername);
            addEntry.setFirstname(pUsername);
            addEntry.setMiddlename(pMiddlename);
            addEntry.setLastname(pLastname);
            addEntry.setSstatus(pStatus);
            addEntry.setEmail(pEmail);
            addEntry.setRoleid(pRoleId);
            addEntry.setStartdate(pStartDate);
            addEntry.setEnddate(pEndDate);
            addEntry.setPid(pPid);
            addEntry.setParentPerson("000000");
            addEntry.setDeleted(0);

            dbServices.insert(addEntry);
            dbServices.commit();

        } catch (Exception e) {

            dbServices.rollback();
            return "FAIL";

        }

    } else {

        //Just update the object here
        //item.setEntityid( pEntityId );        

        //Do the update now.  
        //try{

        //dbServices.begin();
        //    dbServices.update(item);
        //dbServices.commit();

        //} catch (Exception e) {

        //return e.getMessage();

        //}                

        return "FAIL";

    }

    return "OK";

}

From source file:com.waveerp.TableTblEmployeeExt.java

License:Open Source License

public String getTableValue(String pPartyId, String pField) {

    List<Tblemployeeext> myList = null;
    Iterator<Tblemployeeext> iterator = null;
    Tblemployeeext item = null;/*  ww  w .j a  v a  2 s .  c o  m*/

    String strResult = "ERROR";

    try {
        dbServices.begin();

        Session session = dbServices.getDataServiceManager().getSession();
        String sQuery = "select * from Tblemployeeext where partyid = '" + pPartyId + "' ;";

        SQLQuery query = session.createSQLQuery(sQuery);
        query.addEntity(Tblemployeeext.class);

        myList = query.list();

        dbServices.commit();

        iterator = myList.iterator();

        /**
         * At this point, only one record should be retrieved
        */
        while (iterator.hasNext()) {

            item = (Tblemployeeext) iterator.next();

            if (pField.compareTo("ENTITYID") == 0) {

                strResult = (String) item.getEntityid();

            } else if (pField.compareTo("PARENTPERSON") == 0) {

                strResult = (String) item.getParentPerson();

            } else if (pField.compareTo("BADGEID") == 0) {

                strResult = (String) item.getBadgeid();

            } else if (pField.compareTo("DIVISIONID") == 0) {

                strResult = (String) item.getDivisionid();

            } else if (pField.compareTo("DIVISIONDESC") == 0) {

                strResult = (String) item.getDivisiondesc();

            } else if (pField.compareTo("DEPARTMENTID") == 0) {

                strResult = (String) item.getDepartmentid();

            } else if (pField.compareTo("DEPARTMENTDESC") == 0) {

                strResult = (String) item.getDepartmentdesc();

            } else if (pField.compareTo("SECTIONID") == 0) {

                strResult = (String) item.getSectionid();

            } else if (pField.compareTo("SECTIONDESC") == 0) {

                strResult = (String) item.getSectiondesc();

            } else if (pField.compareTo("LOCATIONID") == 0) {

                strResult = (String) item.getLocationid();

            } else if (pField.compareTo("LOCATIONDESC") == 0) {

                strResult = (String) item.getLocationdesc();

            } else if (pField.compareTo("RESTDAYID") == 0) {

                strResult = (String) item.getRestdayid();

            } else if (pField.compareTo("RESTDAYDESC") == 0) {

                strResult = (String) item.getRestdaydesc();

            } else if (pField.compareTo("SHIFTID") == 0) {

                strResult = (String) item.getShiftid();

            } else if (pField.compareTo("SHIFTDESC") == 0) {

                strResult = (String) item.getShiftdesc();

            } else if (pField.compareTo("MANAGERID") == 0) {

                strResult = (String) item.getManagerid();

            } else if (pField.compareTo("MANAGERDESC") == 0) {

                strResult = (String) item.getManagerdesc();

            } else if (pField.compareTo("JUID") == 0) {

                strResult = (String) item.getJuid();

            } else if (pField.compareTo("STATUS") == 0) {

                strResult = (String) item.getSstatus();

            } else {

                strResult = "NULL";

            }

        }

    } catch (Exception e) {

        dbServices.rollback();
        return "FAIL";

    }

    return strResult;

}

From source file:com.waveerp.TableTblOrgLocation.java

License:Open Source License

public String tableOptionData(String pEntityId) {

    String strMsg = "";

    List<Tblorglocation> myList = null;
    Iterator<Tblorglocation> iterator = null;
    Tblorglocation item = null;//from   www.  j av  a 2s .c  o m

    try {

        dbServices.begin();

        Session session = dbServices.getDataServiceManager().getSession();
        String sQuery = "select * from Tblorglocation where entityid ='" + pEntityId + "';";

        SQLQuery query = session.createSQLQuery(sQuery);
        query.addEntity(Tblorglocation.class);
        myList = query.list();

        dbServices.commit();

        iterator = myList.iterator();

        while (iterator.hasNext()) {

            item = (Tblorglocation) iterator.next();

            String txtId = (String) item.getOrgid();

            strMsg = strMsg + "," + txtId;

        }

    } catch (Exception e) {

        dbServices.rollback();
        return "FAIL";

    }

    return strMsg;

}

From source file:com.waveerp.TableTblOrgLocation.java

License:Open Source License

public String getTableValue(String pOrgId, String pField) {

    List<Tblorglocation> myList = null;
    Iterator<Tblorglocation> iterator = null;
    Tblorglocation item = null;/*from www .j a  v a2s  . com*/

    String strResult = "ERROR";

    try {
        dbServices.begin();

        Session session = dbServices.getDataServiceManager().getSession();
        String sQuery = "select * from Tblorglocation where orgid = '" + pOrgId + "' ;";

        SQLQuery query = session.createSQLQuery(sQuery);
        query.addEntity(Tblorglocation.class);

        myList = query.list();

        dbServices.commit();

        iterator = myList.iterator();

        /**
         * At this point, only one record should be retrieved
        */
        while (iterator.hasNext()) {

            item = (Tblorglocation) iterator.next();

            if (pField.compareTo("ENTITYID") == 0) {

                strResult = (String) item.getEntityid();

            } else if (pField.compareTo("DESCRIPTION") == 0) {

                strResult = (String) item.getDescription();

            } else if (pField.compareTo("PID") == 0) {

                strResult = (String) item.getPid();

            } else if (pField.compareTo("CONTACT01") == 0) {

                strResult = (String) item.getContact01();

            } else if (pField.compareTo("CONTACT02") == 0) {

                strResult = (String) item.getContact02();

            } else if (pField.compareTo("GEODESC") == 0) {

                strResult = (String) item.getGeodesc();

            } else if (pField.compareTo("GEOLON") == 0) {

                strResult = ((Double) item.getGeolon()).toString();

            } else if (pField.compareTo("GEOLAT") == 0) {

                strResult = ((Double) item.getGeolat()).toString();

            } else if (pField.compareTo("CATEGORY") == 0) {

                strResult = (String) item.getCategory();

            } else if (pField.compareTo("JUID") == 0) {

                strResult = (String) item.getJuid();

            } else if (pField.compareTo("STATUS") == 0) {

                strResult = (String) item.getSstatus();

            } else {

                strResult = "NULL";

            }

        }

    } catch (Exception e) {

        dbServices.rollback();
        return "FAIL";

    }

    return strResult;

}