Example usage for org.hibernate Query setLong

List of usage examples for org.hibernate Query setLong

Introduction

In this page you can find the example usage for org.hibernate Query setLong.

Prototype

@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setLong(String name, long val) 

Source Link

Document

Bind a named long-valued parameter.

Usage

From source file:de.fhdo.terminologie.ws.search.ListCodeSystemConcepts.java

License:Apache License

public ListCodeSystemConceptsResponseType ListCodeSystemConcepts(ListCodeSystemConceptsRequestType parameter,
        org.hibernate.Session session, boolean noLimit, String ipAddress) {
    if (logger.isInfoEnabled())
        logger.info("====== ListCodeSystemConcepts gestartet ======");

    boolean createHibernateSession = (session == null);

    // Return-Informationen anlegen
    ListCodeSystemConceptsResponseType response = new ListCodeSystemConceptsResponseType();
    response.setReturnInfos(new ReturnType());

    // Parameter prfen
    if (validateParameter(parameter, response) == false) {
        logger.debug("Parameter falsch");
        return response; // Fehler bei den Parametern
    }//from w w  w  .  j av  a  2  s  . c om

    // Login-Informationen auswerten (gilt fr jeden Webservice)
    boolean loggedIn = false;
    AuthenticateInfos loginInfoType = new AuthenticateInfos();
    if (parameter != null && parameter.getLoginToken() != null) {
        loginInfoType = Authorization.authenticate(ipAddress, parameter.getLoginToken());
        loggedIn = loginInfoType != null;
    }

    if (logger.isDebugEnabled()) {
        logger.debug("Benutzer ist eingeloggt: " + loggedIn);
        logger.debug("isLookForward: " + parameter.isLookForward());
    }

    int maxPageSizeUserSpecific = 10;
    //int maxPageSizeUserSpecific = 1;
    if (parameter.getPagingParameter() != null && parameter.getPagingParameter().getUserPaging() != null) {
        if (parameter.getPagingParameter().getUserPaging())
            maxPageSizeUserSpecific = Integer.valueOf(parameter.getPagingParameter().getPageSize());
    } else {
        maxPageSizeUserSpecific = -1;
    }

    // PagingInfo
    int maxPageSize = 100; // Gibt an, wieviele Treffer maximal zurckgegeben werden

    //Warum loggedIn hier? Das ergibt am Termbrowser folgenden Bug: Wenn man eingeloggt ist kann man sich keine HugeFlat Concept Liste mehr ansehen e.g. LOINC! => WrongValueException!
    if (noLimit)// || loggedIn) 
    {
        maxPageSize = -1;
    } else {
        String maxPageSizeStr = SysParameter.instance().getStringValue("maxPageSize", null, null);
        try {
            maxPageSize = Integer.parseInt(maxPageSizeStr);
        } catch (Exception e) {
            LoggingOutput.outputException(e, this);
        }
    }

    boolean traverseConceptsToRoot = false;
    int maxPageSizeSearch = 5; // Gibt an, wieviele Treffer bei einer Suche maximal zurckgegeben werden

    if (parameter != null && parameter.getSearchParameter() != null
            && parameter.getSearchParameter().getTraverseConceptsToRoot() != null
            && parameter.getSearchParameter().getTraverseConceptsToRoot()) {
        traverseConceptsToRoot = true;

        String maxPageSizeSearchStr = SysParameter.instance().getStringValue("maxPageSizeSearch", null, null);
        if (parameter != null && parameter.getSearchParameter() != null) {
            if (maxPageSizeSearchStr != null && maxPageSizeSearchStr.length() > 0) {
                try {
                    maxPageSizeSearch = Integer.parseInt(maxPageSizeSearchStr);
                } catch (Exception e) {
                    LoggingOutput.outputException(e, this);
                }
            }
        }
    }

    //maxPageSizeSearch = 2;
    //maxPageSize = 2;
    logger.debug("maxPageSize: " + maxPageSizeSearch);
    logger.debug("maxPageSizeSearch: " + maxPageSizeSearch);

    logger.debug("traverseConceptsToRoot: " + traverseConceptsToRoot);

    try {
        //List<CodeSystemConcept> conceptList = null;

        String codeSystemVersionOid = "";
        long codeSystemVersionId = 0;
        if (parameter.getCodeSystem().getCodeSystemVersions() != null
                && parameter.getCodeSystem().getCodeSystemVersions().size() > 0) {
            CodeSystemVersion csv = (CodeSystemVersion) parameter.getCodeSystem().getCodeSystemVersions()
                    .toArray()[0];
            if (csv.getVersionId() != null)
                codeSystemVersionId = csv.getVersionId();
            if (csv.getOid() != null)
                codeSystemVersionOid = csv.getOid();
        }

        // Lizenzen prfen
        boolean validLicence = false;
        if (codeSystemVersionOid != null && codeSystemVersionOid.length() > 0)
            validLicence = LicenceHelper.getInstance().userHasLicence(loginInfoType.getUserId(),
                    codeSystemVersionOid);
        else
            validLicence = LicenceHelper.getInstance().userHasLicence(loginInfoType.getUserId(),
                    codeSystemVersionId);

        if (validLicence == false) {
            response.getReturnInfos().setOverallErrorCategory(ReturnType.OverallErrorCategory.WARN);
            response.getReturnInfos().setStatus(ReturnType.Status.FAILURE);
            response.getReturnInfos().setMessage("Sie besitzen keine gltige Lizenz fr dieses Vokabular!");
            return response;
        } else
            logger.debug("Lizenz fr Vokabular vorhanden!");

        // Hibernate-Block, Session ffnen
        //org.hibernate.Session hb_session = HibernateUtil.getSessionFactory().openSession();
        org.hibernate.Session hb_session = null;
        //org.hibernate.Transaction tx = null;

        if (createHibernateSession) {
            hb_session = HibernateUtil.getSessionFactory().openSession();
            //hb_session.getTransaction().begin();
            //tx = hb_session.beginTransaction();
        } else {
            hb_session = session;
            //hb_session.getTransaction().begin();
        }

        try // 2. try-catch-Block zum Abfangen von Hibernate-Fehlern
        {
            if (codeSystemVersionOid != null && codeSystemVersionOid.length() > 0) {
                logger.debug("get csv-id from oid");
                // get csv-id from oid
                String hql = "from CodeSystemVersion csv" + " where csv.oid=:oid";
                Query q = hb_session.createQuery(hql);
                q.setString("oid", codeSystemVersionOid);
                List<CodeSystemVersion> csvList = q.list();
                if (csvList != null && csvList.size() > 0) {
                    codeSystemVersionId = csvList.get(0).getVersionId();
                    logger.debug("found versionId from oid: " + codeSystemVersionId);
                } else {
                    response.setCodeSystemEntity(new LinkedList<CodeSystemEntity>());
                    response.getReturnInfos().setOverallErrorCategory(ReturnType.OverallErrorCategory.WARN);
                    response.getReturnInfos().setStatus(ReturnType.Status.FAILURE);
                    response.getReturnInfos().setMessage("Codesystem with given OID can't be found.");
                    response.getReturnInfos().setCount(0);
                    return response;
                }
            }

            if (codeSystemVersionId == 0 && parameter.getCodeSystem().getId() != null) {
                // Aktuelle Version des Vokabulars ermitteln
                long codeSystemId = parameter.getCodeSystem().getId();

                CodeSystem cs = (CodeSystem) hb_session.get(CodeSystem.class, codeSystemId);
                if (cs != null)
                    codeSystemVersionId = CodeSystemHelper.getCurrentVersionId(cs);
            }

            // HQL erstellen
            // Besonderheit hier: es drfen keine Werte nachgeladen werden
            // Beim Abruf eines ICD wre dieses sehr inperformant, da er fr
            // jeden Eintrag sonst nachladen wrde

            /*
             SELECT * FROM code_system_concept csc
             JOIN code_system_entity_version csev ON csc.codeSystemEntityVersionId=csev.versionId
             JOIN code_system_entity cse ON csev.versionId=cse.id
             JOIN code_system_version_entity_membership csvem ON cse.id=csvem.codeSystemEntityId
             LEFT JOIN code_system_concept_translation csct ON csct.codeSystemEntityVersionId=csc.codeSystemEntityVersionId
             WHERE csvem.codeSystemVersionId=10
             */
            String languageCd = "";

            /*SELECT * FROM
             (SELECT csc.*, csev.*, csvem.isAxis, csvem.isMainClass, cse.* FROM code_system_concept csc
             JOIN code_system_entity_version csev ON csc.codeSystemEntityVersionId=csev.versionId
             JOIN code_system_entity cse ON csev.versionId=cse.id
             JOIN code_system_version_entity_membership csvem ON cse.id=csvem.codeSystemEntityId
             WHERE csvem.codeSystemVersionId=10 LIMIT 2) csc2
             LEFT JOIN code_system_concept_translation csct ON csct.codeSystemEntityVersionId=csc2.codeSystemEntityVersionId*/
            //
            //String sql = "SELECT * FROM (SELECT csc.*, csev.*, csvem.isAxis, csvem.isMainClass, cse.* FROM code_system_concept csc"
            String sql = "SELECT * FROM (SELECT csc.*, csev.*, csvem.isAxis, csvem.isMainClass, cse.*, csct.term translation_term, csct.termAbbrevation translation_termAbbrevation, csct.description translation_description, csct.languageCd translation_languageCd, csct.id translation_id "
                    + " FROM code_system_concept csc"
                    + " JOIN code_system_entity_version csev ON csc.codeSystemEntityVersionId=csev.versionId"
                    + " JOIN code_system_entity cse ON csev.codeSystemEntityId=cse.id"
                    + " JOIN code_system_version_entity_membership csvem ON cse.id=csvem.codeSystemEntityId"
                    + " LEFT JOIN code_system_concept_translation csct ON csct.codeSystemEntityVersionId=csc.codeSystemEntityVersionId AND languageCd=:languageCd"
                    //+ " LEFT JOIN code_system_concept_translation csct ON csct.codeSystemEntityVersionId=csc.codeSystemEntityVersionId AND_LANGUAGE_TERM"
                    + " WHERE_TEIL) csc2"
                    //+ " LEFT JOIN code_system_concept_translation csct ON csct.codeSystemEntityVersionId=csc2.codeSystemEntityVersionId";
                    + " LEFT JOIN code_system_entity_version_association cseva1 ON cseva1.codeSystemEntityVersionId1=csc2.versionId"
                    + " LEFT JOIN code_system_entity_version_association cseva2 ON cseva2.codeSystemEntityVersionId2=csc2.versionId";

            String sqlCount = "SELECT COUNT(*) FROM code_system_concept csc"
                    + " JOIN code_system_entity_version csev ON csc.codeSystemEntityVersionId=csev.versionId"
                    + " JOIN code_system_entity cse ON csev.versionId=cse.id"
                    + " JOIN code_system_version_entity_membership csvem ON cse.id=csvem.codeSystemEntityId"
                    + " WHERE_TEIL";

            /*String sql = " FROM code_system_concept csc"
             + " JOIN code_system_entity_version csev ON csc.codeSystemEntityVersionId=csev.versionId"
             + " JOIN code_system_entity cse ON csev.versionId=cse.id"
             + " JOIN code_system_version_entity_membership csvem ON cse.id=csvem.codeSystemEntityId"
             + " LEFT JOIN code_system_concept_translation csct ON csct.codeSystemEntityVersionId=csc.codeSystemEntityVersionId";*/
            //+ " WHERE csvem.codeSystemVersionId=:codeSystemVersionId"
            //+ " GROUP BY csc.code"
            //+ " ORDER BY csc.code";
            // Parameter dem Helper hinzufgen
            // bitte immer den Helper verwenden oder manuell Parameter per Query.setString() hinzufgen,
            // sonst sind SQL-Injections mglich
            HQLParameterHelper parameterHelper = new HQLParameterHelper();
            parameterHelper.addParameter("", "csvem.codeSystemVersionId", codeSystemVersionId);

            if (parameter != null && parameter.getCodeSystemEntity() != null) {
                if (parameter.getCodeSystemEntity().getCodeSystemVersionEntityMemberships() != null
                        && parameter.getCodeSystemEntity().getCodeSystemVersionEntityMemberships().size() > 0) {
                    CodeSystemVersionEntityMembership ms = (CodeSystemVersionEntityMembership) parameter
                            .getCodeSystemEntity().getCodeSystemVersionEntityMemberships().toArray()[0];
                    parameterHelper.addParameter("csvem.", "isAxis", ms.getIsAxis());
                    parameterHelper.addParameter("csvem.", "isMainClass", ms.getIsMainClass());
                }

                if (parameter.getCodeSystemEntity().getCodeSystemEntityVersions() != null
                        && parameter.getCodeSystemEntity().getCodeSystemEntityVersions().size() > 0) {
                    CodeSystemEntityVersion csev = (CodeSystemEntityVersion) parameter.getCodeSystemEntity()
                            .getCodeSystemEntityVersions().toArray()[0];
                    parameterHelper.addParameter("csev.", "statusVisibilityDate",
                            csev.getStatusVisibilityDate());

                    if (csev.getCodeSystemConcepts() != null && csev.getCodeSystemConcepts().size() > 0) {
                        CodeSystemConcept csc = (CodeSystemConcept) csev.getCodeSystemConcepts().toArray()[0];
                        parameterHelper.addParameter("csc.", "code", csc.getCode());
                        parameterHelper.addParameter("csc.", "term", csc.getTerm());
                        parameterHelper.addParameter("csc.", "termAbbrevation", csc.getTermAbbrevation());
                        parameterHelper.addParameter("csc.", "isPreferred", csc.getIsPreferred());

                        if (csc.getCodeSystemConceptTranslations() != null
                                && csc.getCodeSystemConceptTranslations().size() > 0) {
                            CodeSystemConceptTranslation csct = (CodeSystemConceptTranslation) csc
                                    .getCodeSystemConceptTranslations().toArray()[0];
                            parameterHelper.addParameter("csct.", "term", csct.getTerm());
                            parameterHelper.addParameter("csct.", "termAbbrevation", csct.getTermAbbrevation());
                            if (csct.getLanguageCd() != null && csct.getLanguageCd().length() > 0) {
                                languageCd = csct.getLanguageCd();
                            }
                        }
                    }
                }
            }

            /*if(languageCd.length() == 0)
             sql = sql.replaceAll("AND_LANGUAGE_TERM", "");
             else 
             sql = sql.replaceAll("AND_LANGUAGE_TERM", "AND languageCd=:languageCd");*/
            if (loggedIn == false) {
                parameterHelper.addParameter("csev.", "statusVisibility",
                        Definitions.STATUS_CODES.ACTIVE.getCode());
            }

            // Parameter hinzufgen (immer mit AND verbunden)
            // Gesamt-Anzahl lesen
            String where = parameterHelper.getWhere("");

            //sqlCount = "SELECT COUNT(DISTINCT cse.id) FROM " + sqlCount.replaceAll("WHERE_TEIL", where);
            sqlCount = sqlCount.replaceAll("WHERE_TEIL", where);

            //q.addScalar("csc.code", Hibernate.TEXT);  // Index: 0
            logger.debug("SQL-Count: " + sqlCount);
            SQLQuery qCount = hb_session.createSQLQuery(sqlCount);
            parameterHelper.applySQLParameter(qCount);
            BigInteger anzahlGesamt = (BigInteger) qCount.uniqueResult();

            logger.debug("Anzahl Gesamt: " + anzahlGesamt.longValue());

            if (anzahlGesamt.longValue() > 0) {
                // Suche begrenzen
                int pageSize = -1;
                int pageIndex = 0;
                boolean allEntries = false;

                if (parameter != null && parameter.getPagingParameter() != null) {
                    logger.debug("Search-Parameter angegeben");
                    if (parameter.getPagingParameter().isAllEntries() != null
                            && parameter.getPagingParameter().isAllEntries().booleanValue() == true) {
                        if (loggedIn)
                            allEntries = true;
                    }

                    if (parameter.getPagingParameter().getPageSize() != null)
                        pageSize = Integer.valueOf(parameter.getPagingParameter().getPageSize());
                    if (parameter.getPagingParameter().getPageIndex() != null)
                        pageIndex = parameter.getPagingParameter().getPageIndex();
                }

                // MaxResults mit Wert aus SysParam prfen
                if (traverseConceptsToRoot) {
                    if (pageSize < 0 || (maxPageSizeSearch > 0 && pageSize > maxPageSizeSearch))
                        pageSize = maxPageSizeSearch;
                } else {
                    if (pageSize < 0 || (maxPageSize > 0 && pageSize > maxPageSize))
                        pageSize = maxPageSize;
                }
                if (pageIndex < 0)
                    pageIndex = 0;

                logger.debug("pageIndex: " + pageIndex);
                logger.debug("pageSize: " + pageSize);

                /*String sortStr = " ORDER BY csc.code";
                        
                 if (parameter.getSortingParameter() != null)
                 {
                 if (parameter.getSortingParameter().getSortType() == null
                 || parameter.getSortingParameter().getSortType() == SortingType.SortType.ALPHABETICALLY)
                 {
                 sortStr = " ORDER BY";
                        
                 if (parameter.getSortingParameter().getSortBy() != null
                 && parameter.getSortingParameter().getSortBy() == SortingType.SortByField.TERM)
                 {
                 sortStr += " csc.term";
                 }
                 else
                 {
                 sortStr += " csc.code";
                 }
                        
                 if (parameter.getSortingParameter().getSortDirection() != null
                 && parameter.getSortingParameter().getSortDirection() == SortingType.SortDirection.DESCENDING)
                 {
                 sortStr += " desc";
                 }
                        
                 }
                 }*/
                String sortStr = " ORDER BY code";

                if (parameter.getSortingParameter() != null) {
                    if (parameter.getSortingParameter().getSortType() == null || parameter.getSortingParameter()
                            .getSortType() == SortingType.SortType.ALPHABETICALLY) {
                        sortStr = " ORDER BY";

                        if (parameter.getSortingParameter().getSortBy() != null && parameter
                                .getSortingParameter().getSortBy() == SortingType.SortByField.TERM) {
                            sortStr += " term";
                        } else {
                            sortStr += " code";
                        }

                        if (parameter.getSortingParameter().getSortDirection() != null
                                && parameter.getSortingParameter()
                                        .getSortDirection() == SortingType.SortDirection.DESCENDING) {
                            sortStr += " desc";
                        }

                    }
                }

                /*String where_all = where + sortStr;
                        
                 if (pageSize > 0 && allEntries == false)
                 {
                 where_all += " LIMIT " + (pageIndex * pageSize) + "," + pageSize;
                 }
                        
                 sql = sql.replaceAll("WHERE_TEIL", where_all);*/
                if (pageSize > 0 && allEntries == false) {
                    sortStr += " LIMIT " + (pageIndex * pageSize) + "," + pageSize;
                }

                sql = sql.replaceAll("WHERE_TEIL", where);
                sql += sortStr;

                int anzahl = 0;
                //logger.debug("SQL: " + sql);
                // Query erstellen
                SQLQuery q = hb_session.createSQLQuery(sql);
                q.addScalar("csc2.code", StandardBasicTypes.TEXT); // Index: 0
                q.addScalar("csc2.term", StandardBasicTypes.TEXT);
                q.addScalar("csc2.termAbbrevation", StandardBasicTypes.TEXT);
                q.addScalar("csc2.description", StandardBasicTypes.TEXT);
                q.addScalar("csc2.isPreferred", StandardBasicTypes.BOOLEAN);
                q.addScalar("csc2.codeSystemEntityVersionId", StandardBasicTypes.LONG);

                q.addScalar("csc2.effectiveDate", StandardBasicTypes.TIMESTAMP); // Index: 6
                q.addScalar("csc2.insertTimestamp", StandardBasicTypes.TIMESTAMP);
                q.addScalar("csc2.isLeaf", StandardBasicTypes.BOOLEAN);
                q.addScalar("csc2.majorRevision", StandardBasicTypes.INTEGER);
                q.addScalar("csc2.minorRevision", StandardBasicTypes.INTEGER);
                q.addScalar("csc2.statusVisibility", StandardBasicTypes.INTEGER);
                q.addScalar("csc2.statusVisibilityDate", StandardBasicTypes.TIMESTAMP);
                q.addScalar("csc2.versionId", StandardBasicTypes.LONG);
                q.addScalar("csc2.codeSystemEntityId", StandardBasicTypes.LONG);

                q.addScalar("csc2.id", StandardBasicTypes.LONG); // Index: 15
                q.addScalar("csc2.currentVersionId", StandardBasicTypes.LONG);

                q.addScalar("csc2.isAxis", StandardBasicTypes.BOOLEAN); // Index: 17
                q.addScalar("csc2.isMainClass", StandardBasicTypes.BOOLEAN);

                q.addScalar("translation_term", StandardBasicTypes.TEXT); // Index: 19
                q.addScalar("translation_termAbbrevation", StandardBasicTypes.TEXT);
                q.addScalar("translation_languageCd", StandardBasicTypes.TEXT);
                q.addScalar("translation_description", StandardBasicTypes.TEXT);
                q.addScalar("translation_id", StandardBasicTypes.LONG);

                q.addScalar("cseva1.codeSystemEntityVersionId1", StandardBasicTypes.LONG); // Index: 24
                q.addScalar("cseva1.codeSystemEntityVersionId2", StandardBasicTypes.LONG);
                q.addScalar("cseva1.leftId", StandardBasicTypes.LONG);
                q.addScalar("cseva1.associationTypeId", StandardBasicTypes.LONG);
                q.addScalar("cseva1.associationKind", StandardBasicTypes.INTEGER);
                q.addScalar("cseva1.status", StandardBasicTypes.INTEGER);
                q.addScalar("cseva1.statusDate", StandardBasicTypes.TIMESTAMP);
                q.addScalar("cseva1.insertTimestamp", StandardBasicTypes.TIMESTAMP);

                q.addScalar("csc2.meaning", StandardBasicTypes.TEXT); //Index: 32
                q.addScalar("csc2.hints", StandardBasicTypes.TEXT);

                q.addScalar("csc2.statusDeactivated", StandardBasicTypes.INTEGER); // Index: 34
                q.addScalar("csc2.statusDeactivatedDate", StandardBasicTypes.TIMESTAMP);
                q.addScalar("csc2.statusWorkflow", StandardBasicTypes.INTEGER);
                q.addScalar("csc2.statusWorkflowDate", StandardBasicTypes.TIMESTAMP);

                q.addScalar("cseva2.codeSystemEntityVersionId1", StandardBasicTypes.LONG); // Index: 38
                q.addScalar("cseva2.codeSystemEntityVersionId2", StandardBasicTypes.LONG);
                q.addScalar("cseva2.leftId", StandardBasicTypes.LONG);
                q.addScalar("cseva2.associationTypeId", StandardBasicTypes.LONG);
                q.addScalar("cseva2.associationKind", StandardBasicTypes.INTEGER);
                q.addScalar("cseva2.status", StandardBasicTypes.INTEGER);
                q.addScalar("cseva2.statusDate", StandardBasicTypes.TIMESTAMP);
                q.addScalar("cseva2.insertTimestamp", StandardBasicTypes.TIMESTAMP);

                parameterHelper.applySQLParameter(q);
                //if(languageCd.length() > 0)
                q.setString("languageCd", languageCd);

                response.setCodeSystemEntity(new LinkedList<CodeSystemEntity>());

                logger.debug("SQL: " + q.getQueryString());

                List conceptList = (List) q.list();

                Iterator it = conceptList.iterator();

                long lastCodeSystemEntityVersionId = 0;
                CodeSystemEntity cse = new CodeSystemEntity();
                CodeSystemEntityVersion csev = new CodeSystemEntityVersion();
                CodeSystemConcept csc = new CodeSystemConcept();
                CodeSystemVersionEntityMembership csvem = new CodeSystemVersionEntityMembership();
                boolean fertig = false;

                while (it.hasNext()) {
                    Object[] item = null;
                    long codeSystemEntityVersionId = 0;
                    do {
                        if (it.hasNext() == false) {
                            fertig = true;
                            break;
                        }

                        item = (Object[]) it.next();

                        // Prfen, ob Translation (1:N)
                        codeSystemEntityVersionId = (Long) item[5];
                        if (lastCodeSystemEntityVersionId == codeSystemEntityVersionId) {
                            // Gleiches Konzept, Assoziation hinzufgen
                            if (parameter.isLookForward())
                                addAssociationToEntityVersion(csev, item);
                        }
                    } while (lastCodeSystemEntityVersionId == codeSystemEntityVersionId);

                    if (fertig)
                        break;

                    // Konzepte zusammenbauen
                    cse = new CodeSystemEntity();
                    csev = new CodeSystemEntityVersion();
                    csc = new CodeSystemConcept();
                    csvem = new CodeSystemVersionEntityMembership();

                    // Konzept
                    if (item[0] != null)
                        csc.setCode(item[0].toString());
                    if (item[1] != null)
                        csc.setTerm(item[1].toString());
                    if (item[2] != null)
                        //csc.setTermAbbrevation(new String((char[])item[2]));
                        csc.setTermAbbrevation(item[2].toString());
                    if (item[3] != null)
                        csc.setDescription(item[3].toString());
                    if (item[4] != null)
                        csc.setIsPreferred((Boolean) item[4]);
                    if (item[5] != null)
                        csc.setCodeSystemEntityVersionId((Long) item[5]);

                    if (item[32] != null)
                        csc.setMeaning(item[32].toString());
                    if (item[33] != null)
                        csc.setHints(item[33].toString());

                    // Entity Version
                    if (item[6] != null)
                        csev.setEffectiveDate(DateHelper.getDateFromObject(item[6]));
                    if (item[7] != null)
                        csev.setInsertTimestamp(DateHelper.getDateFromObject(item[7]));
                    if (item[8] != null)
                        csev.setIsLeaf((Boolean) item[8]);
                    if (item[9] != null)
                        csev.setMajorRevision((Integer) item[9]);
                    if (item[10] != null)
                        csev.setMinorRevision((Integer) item[10]);
                    if (item[11] != null)
                        csev.setStatusVisibility((Integer) item[11]);
                    if (item[12] != null)
                        csev.setStatusVisibilityDate(DateHelper.getDateFromObject(item[12]));
                    if (item[13] != null)
                        csev.setVersionId((Long) item[13]);

                    if (item[34] != null)
                        csev.setStatusDeactivated((Integer) item[34]);
                    if (item[35] != null)
                        csev.setStatusDeactivatedDate(DateHelper.getDateFromObject(item[35]));
                    if (item[36] != null)
                        csev.setStatusWorkflow((Integer) item[36]);
                    if (item[37] != null)
                        csev.setStatusWorkflowDate(DateHelper.getDateFromObject(item[37]));

                    // Code System Entity
                    if (item[15] != null)
                        cse.setId((Long) item[15]);
                    if (item[16] != null)
                        cse.setCurrentVersionId((Long) item[16]);

                    // Entity Membership
                    if (item[17] != null)
                        csvem.setIsAxis((Boolean) item[17]);
                    if (item[18] != null)
                        csvem.setIsMainClass((Boolean) item[18]);

                    // Translation
                    addTranslationToConcept(csc, item);

                    // Assoziation
                    if (parameter.isLookForward())
                        addAssociationToEntityVersion(csev, item);

                    if (traverseConceptsToRoot) {
                        // Alle Elemente bis zum Root ermitteln (fr Suche)
                        TraverseConceptToRoot traverse = new TraverseConceptToRoot();
                        TraverseConceptToRootRequestType requestTraverse = new TraverseConceptToRootRequestType();
                        requestTraverse.setLoginToken(parameter.getLoginToken());
                        requestTraverse.setCodeSystemEntity(new CodeSystemEntity());
                        CodeSystemEntityVersion csevRequest = new CodeSystemEntityVersion();
                        csevRequest.setVersionId(csev.getVersionId());
                        requestTraverse.getCodeSystemEntity()
                                .setCodeSystemEntityVersions(new HashSet<CodeSystemEntityVersion>());
                        requestTraverse.getCodeSystemEntity().getCodeSystemEntityVersions().add(csevRequest);

                        requestTraverse.setDirectionToRoot(true);
                        //TraverseConceptToRootResponseType responseTraverse = traverse.TraverseConceptToRoot(requestTraverse, hb_session); // die Session bergeben, damit diese nicht geschlossen wird
                        TraverseConceptToRootResponseType responseTraverse = traverse
                                .TraverseConceptToRoot(requestTraverse, null);

                        //logger.debug("responseTraverse: " + responseTraverse.getReturnInfos().getMessage());
                        if (responseTraverse.getReturnInfos().getStatus() == ReturnType.Status.OK) {
                            if (csev.getCodeSystemEntityVersionAssociationsForCodeSystemEntityVersionId1() == null) {
                                csev.setCodeSystemEntityVersionAssociationsForCodeSystemEntityVersionId1(
                                        responseTraverse.getCodeSystemEntityVersionRoot()
                                                .getCodeSystemEntityVersionAssociationsForCodeSystemEntityVersionId1());
                            } else {
                                csev.getCodeSystemEntityVersionAssociationsForCodeSystemEntityVersionId1()
                                        .addAll(responseTraverse.getCodeSystemEntityVersionRoot()
                                                .getCodeSystemEntityVersionAssociationsForCodeSystemEntityVersionId1());
                            }
                        }
                    }

                    if (parameter.isLoadMetadata() != null && parameter.isLoadMetadata().booleanValue()) {
                        String hql = "from CodeSystemMetadataValue mv " + " join fetch mv.metadataParameter mp "
                                + " where codeSystemEntityVersionId=:csev_id";

                        Query query = hb_session.createQuery(hql);
                        query.setLong("csev_id", csev.getVersionId());
                        csev.setCodeSystemMetadataValues(new HashSet<CodeSystemMetadataValue>(query.list()));

                        // remove circle problems
                        for (CodeSystemMetadataValue mv : csev.getCodeSystemMetadataValues()) {
                            mv.setCodeSystemEntityVersion(null);
                            mv.getMetadataParameter().setCodeSystem(null);
                            mv.getMetadataParameter().setValueSet(null);
                            mv.getMetadataParameter().setValueSetMetadataValues(null);
                            mv.getMetadataParameter().setCodeSystemMetadataValues(null);
                            mv.getMetadataParameter().setDescription(null);
                            mv.getMetadataParameter().setMetadataParameterType(null);
                        }
                    }

                    if (parameter.isLoadTranslation() != null && parameter.isLoadTranslation().booleanValue()) {
                        String hql = "from CodeSystemConceptTranslation csct "
                                + " where codeSystemEntityVersionId=:csev_id";
                        //+ " order by csct.languageCd";

                        Query query = hb_session.createQuery(hql);
                        query.setLong("csev_id", csev.getVersionId());
                        csc.setCodeSystemConceptTranslations(
                                new HashSet<CodeSystemConceptTranslation>(query.list()));

                        // remove circle problems
                        for (CodeSystemConceptTranslation trans : csc.getCodeSystemConceptTranslations()) {
                            trans.setCodeSystemConcept(null);
                        }
                    }

                    //logger.debug(csc.getCode());
                    //logger.debug("Type: " + csc.getClass().getCanonicalName());
                    /*Object[] o = (Object[]) csc;
                     for(int i=0;i<o.length;++i)
                     {
                     //logger.debug(i + ": " + o.toString());
                     if(o[i] != null)
                     {
                     logger.debug(i + ": " + o[i].toString());
                     logger.debug(i + ": " + o[i].getClass().getCanonicalName());
                     }
                     else logger.debug(i + ": null");
                              
                     //for(int j=0;j<)
                     }*/
                    csev.setCodeSystemConcepts(new HashSet<CodeSystemConcept>());
                    csev.getCodeSystemConcepts().add(csc);
                    cse.setCodeSystemEntityVersions(new HashSet<CodeSystemEntityVersion>());
                    cse.getCodeSystemEntityVersions().add(csev);
                    cse.setCodeSystemVersionEntityMemberships(new HashSet<CodeSystemVersionEntityMembership>());
                    cse.getCodeSystemVersionEntityMemberships().add(csvem);
                    response.getCodeSystemEntity().add(cse);

                    lastCodeSystemEntityVersionId = codeSystemEntityVersionId;

                    anzahl++;
                }

                // Treffermenge prfen            
                // Paging wird aktiviert
                if (anzahlGesamt.longValue() > maxPageSize) {
                    response.setPagingInfos(new PagingResultType());
                    response.getPagingInfos().setMaxPageSize(maxPageSize);
                    response.getPagingInfos().setPageIndex(pageIndex);
                    response.getPagingInfos().setPageSize(String.valueOf(pageSize));
                    response.getPagingInfos().setCount(anzahlGesamt.intValue());
                    if (parameter != null && parameter.getPagingParameter() != null) {
                        response.getPagingInfos().setMessage(
                                "Paging wurde aktiviert, da die Treffermenge grer ist als die maximale Seitengre.");
                    }
                } else {

                    if ((maxPageSizeUserSpecific != -1) && anzahlGesamt.longValue() > maxPageSizeUserSpecific) {

                        response.setPagingInfos(new PagingResultType());
                        response.getPagingInfos().setMaxPageSize(maxPageSizeUserSpecific);
                        response.getPagingInfos().setPageIndex(pageIndex);
                        response.getPagingInfos().setPageSize(String.valueOf(maxPageSizeUserSpecific));
                        response.getPagingInfos().setCount(anzahlGesamt.intValue());
                        if (parameter != null && parameter.getPagingParameter() != null) {
                            response.getPagingInfos().setMessage(
                                    "Paging wurde aktiviert, da popUpSearchCS spezifische Seitenanzahl.");
                        }
                    }
                }

                // Status an den Aufrufer weitergeben            
                response.getReturnInfos().setOverallErrorCategory(ReturnType.OverallErrorCategory.INFO);
                response.getReturnInfos().setStatus(ReturnType.Status.OK);
                response.getReturnInfos().setMessage("Konzepte erfolgreich gelesen, Anzahl: " + anzahl);
                response.getReturnInfos().setCount(anzahl);
            } else {
                response.setCodeSystemEntity(new LinkedList<CodeSystemEntity>());
                response.getReturnInfos().setOverallErrorCategory(ReturnType.OverallErrorCategory.INFO);
                response.getReturnInfos().setStatus(ReturnType.Status.OK);
                response.getReturnInfos().setMessage("Keine Konzepte fr die Filterkriterien vorhanden");
                response.getReturnInfos().setCount(0);
            }
            /*String hql = "select distinct csc from CodeSystemConcept csc";
             hql += " join fetch csc.codeSystemEntityVersion csev";
             hql += " join fetch csev.codeSystemEntity cse";
             hql += " left outer join fetch csc.codeSystemConceptTranslations csct";
             hql += " join fetch cse.codeSystemVersionEntityMemberships csvem";
                    
             //if (parameter.isLookForward())
             //{
             //  hql += " join fetch csev.codeSystemEntityVersionAssociationsForCodeSystemEntityVersionId1 ass1";
             //  hql += " join fetch csev.codeSystemEntityVersionAssociationsForCodeSystemEntityVersionId2 ass2";
             //}
                    
             // Parameter dem Helper hinzufgen
             // bitte immer den Helper verwenden oder manuell Parameter per Query.setString() hinzufgen,
             // sonst sind SQL-Injections mglich
             HQLParameterHelper parameterHelper = new HQLParameterHelper();
             parameterHelper.addParameter("", "codeSystemVersionId", codeSystemVersionId);
                    
             if (parameter != null && parameter.getCodeSystemEntity() != null)
             {
             if (parameter.getCodeSystemEntity().getCodeSystemVersionEntityMemberships() != null
             && parameter.getCodeSystemEntity().getCodeSystemVersionEntityMemberships().size() > 0)
             {
             CodeSystemVersionEntityMembership ms = (CodeSystemVersionEntityMembership) parameter.getCodeSystemEntity().getCodeSystemVersionEntityMemberships().toArray()[0];
             parameterHelper.addParameter("csvem.", "isAxis", ms.getIsAxis());
             parameterHelper.addParameter("csvem.", "isMainClass", ms.getIsMainClass());
             }
                    
             if (parameter.getCodeSystemEntity().getCodeSystemEntityVersions() != null
             && parameter.getCodeSystemEntity().getCodeSystemEntityVersions().size() > 0)
             {
             CodeSystemEntityVersion csev = (CodeSystemEntityVersion) parameter.getCodeSystemEntity().getCodeSystemEntityVersions().toArray()[0];
             parameterHelper.addParameter("csev.", "statusDate", csev.getStatusDate());
                    
             if (csev.getCodeSystemConcepts() != null && csev.getCodeSystemConcepts().size() > 0)
             {
             CodeSystemConcept csc = (CodeSystemConcept) csev.getCodeSystemConcepts().toArray()[0];
             parameterHelper.addParameter("csc.", "code", csc.getCode());
             parameterHelper.addParameter("csc.", "term", csc.getTerm());
             parameterHelper.addParameter("csc.", "termAbbrevation", csc.getTermAbbrevation());
             parameterHelper.addParameter("csc.", "isPreferred", csc.getIsPreferred());
                    
             if (csc.getCodeSystemConceptTranslations() != null && csc.getCodeSystemConceptTranslations().size() > 0)
             {
             CodeSystemConceptTranslation csct = (CodeSystemConceptTranslation) csc.getCodeSystemConceptTranslations().toArray()[0];
             parameterHelper.addParameter("csct.", "term", csct.getTerm());
             parameterHelper.addParameter("csct.", "termAbbrevation", csct.getTermAbbrevation());
             if (csct.getLanguageId() > 0)
             parameterHelper.addParameter("csct.", "languageId", csct.getLanguageId());
             }
             }
             }
             }
                    
             if (loggedIn == false)
             {
             parameterHelper.addParameter("csev.", "status", Definitions.STATUS_CODES.ACTIVE.getCode());
             }
                    
             // Parameter hinzufgen (immer mit AND verbunden)
             String where = parameterHelper.getWhere("");
             hql += where;
                    
             // immer neueste Version lesen
             hql += " AND csev.id=cse.currentVersionId";
                    
             hql += " ORDER BY csc.code";
                    
                    
                    
             // Suche begrenzen
             int pageSize = -1;
             int pageIndex = 0;
             boolean allEntries = false;
                    
             if (parameter != null && parameter.getPagingParameter() != null)
             {
             // vorher aber noch die Gesamtanzahl berechnen
             //Integer count = (Integer) hb_session.createQuery("select count(*) from ....").uniqueResult();
                    
             if (parameter.getPagingParameter().isAllEntries() != null && parameter.getPagingParameter().isAllEntries().booleanValue() == true)
             {
             if (loggedIn)
             allEntries = true;
             }
                    
             pageSize = parameter.getPagingParameter().getPageSize();
             pageIndex = parameter.getPagingParameter().getPageIndex();
             }
                    
             // MaxResults mit Wert aus SysParam prfen
             if (traverseConceptsToRoot)
             {
             if (pageSize < 0 || (maxPageSizeSearch > 0 && pageSize > maxPageSizeSearch))
             pageSize = maxPageSizeSearch;
             }
             else
             {
             if (pageSize < 0 || (maxPageSize > 0 && pageSize > maxPageSize))
             pageSize = maxPageSize;
             }
             if (pageIndex < 0)
             pageIndex = 0;
                    
             // Gesamt-Anzahl lesen
             String hqlCount = "select count(term) from CodeSystemConcept csc";
             hqlCount += " join  csc.codeSystemEntityVersion csev";
             hqlCount += " join  csev.codeSystemEntity cse";
             hqlCount += " join  cse.codeSystemVersionEntityMemberships csvem";
             hqlCount += where;
                    
             //hql = hql.replace("distinct csc", "count(term)");
             logger.debug("HQL-Count: " + hqlCount);
             org.hibernate.Query q = hb_session.createQuery(hqlCount);
                    
             // Die Parameter knnen erst hier gesetzt werden (bernimmt Helper)
             parameterHelper.applyParameter(q);
             long anzahlGesamt = (Long) q.uniqueResult();
                    
             // Anzahl zhlen Datenbank-Aufruf durchfhren
             //int anzahlGesamt = q.list().size();
             //int anzahlGesamt = 100;  // TODO Gesamt-Anzahl herausbekommen
             logger.debug("Anzahl Gesamt: " + anzahlGesamt);
                    
                    
             logger.debug("HQL: " + hql);
             // Query erstellen
             q = hb_session.createQuery(hql);
                    
             // Die Parameter knnen erst hier gesetzt werden (bernimmt Helper)
             parameterHelper.applyParameter(q);
                    
                    
             //conceptList = (java.util.List<CodeSystemConcept>) q.list();
             if (anzahlGesamt > 0)
             {
             //hb_session.setFlushMode(FlushMode.AUTO);
                    
             ScrollableResults scrollResults = q.scroll();
                    
             int itCount = 0;
                    
             if (scrollResults != null)
             {
             java.util.List<CodeSystemEntity> entityList = new LinkedList<CodeSystemEntity>();
                    
             if (pageIndex > 0 && allEntries == false && anzahlGesamt > 0)
             {
             // Vorspulen
             //if(pageSize * pageIndex < anzahlGesamt)
             //  scrollResults.setRowNumber(pageSize * pageIndex);
             for (int i = 0; i < pageSize * pageIndex && i < anzahlGesamt; ++i)
             {
             if (scrollResults.next() == false)
             break;
                    
             if (i % 50 == 0)
             {
             // wichtig, da Speicher sonst voll luft
             hb_session.flush();
             hb_session.clear();
             }
             }
             }
                    
             //Iterator<CodeSystemConcept> iterator = conceptList.iterator();
             //while (iterator.hasNext())
                    
             try
             {
             while (scrollResults.next())
             {
             if (itCount >= pageSize && allEntries == false)
             break;
                    
             if (itCount % 50 == 0)
             {
             // wichtig, da Speicher sonst voll luft
             //hb_session.flush();
             hb_session.clear();
             }
             itCount++;
                    
             //CodeSystemConcept csc = iterator.next();
             CodeSystemConcept csc = (CodeSystemConcept) scrollResults.get(0);
                    
             // neues Entity generieren, damit nicht nachgeladen werden muss
             CodeSystemEntity entity = csc.getCodeSystemEntityVersion().getCodeSystemEntity();
                    
             CodeSystemEntityVersion csev = csc.getCodeSystemEntityVersion();
                    
             csev.setCodeSystemEntity(null);
                    
             if (parameter.isLookForward())
             {
             // Verbindungen suchen
             if (csev.getCodeSystemEntityVersionAssociationsForCodeSystemEntityVersionId2() != null)
             {
             for (CodeSystemEntityVersionAssociation ass : csev.getCodeSystemEntityVersionAssociationsForCodeSystemEntityVersionId2())
             {
             ass.setCodeSystemEntityVersionByCodeSystemEntityVersionId1(null);
             ass.setCodeSystemEntityVersionByCodeSystemEntityVersionId2(null);
             ass.setAssociationType(null);
             }
             }
             if (csev.getCodeSystemEntityVersionAssociationsForCodeSystemEntityVersionId1() != null)
             {
             for (CodeSystemEntityVersionAssociation ass : csev.getCodeSystemEntityVersionAssociationsForCodeSystemEntityVersionId1())
             {
             ass.setCodeSystemEntityVersionByCodeSystemEntityVersionId1(null);
             ass.setCodeSystemEntityVersionByCodeSystemEntityVersionId2(null);
             ass.setAssociationType(null);
             }
             }
             }
             else
             {
             if (traverseConceptsToRoot)
             {
             // Alle Elemente bis zum Root ermitteln (fr Suche)
             TraverseConceptToRoot traverse = new TraverseConceptToRoot();
             TraverseConceptToRootRequestType requestTraverse = new TraverseConceptToRootRequestType();
             requestTraverse.setLoginToken(parameter.getLoginToken());
             requestTraverse.setCodeSystemEntity(new CodeSystemEntity());
             CodeSystemEntityVersion csevRequest = new CodeSystemEntityVersion();
             csevRequest.setVersionId(csev.getVersionId());
             requestTraverse.getCodeSystemEntity().setCodeSystemEntityVersions(new HashSet<CodeSystemEntityVersion>());
             requestTraverse.getCodeSystemEntity().getCodeSystemEntityVersions().add(csevRequest);
                    
             requestTraverse.setDirectionToRoot(true);
             requestTraverse.setReadEntityDetails(false);
             TraverseConceptToRootResponseType responseTraverse = traverse.TraverseConceptToRoot(requestTraverse, hb_session); // die Session bergeben, damit diese nicht geschlossen wird
                    
             //logger.debug("responseTraverse: " + responseTraverse.getReturnInfos().getMessage());
                    
             if (responseTraverse.getReturnInfos().getStatus() == ReturnType.Status.OK)
             {
             csev.setCodeSystemEntityVersionAssociationsForCodeSystemEntityVersionId1(
             responseTraverse.getCodeSystemEntityVersionRoot().getCodeSystemEntityVersionAssociationsForCodeSystemEntityVersionId1());
             }
             else
             {
             csev.setCodeSystemEntityVersionAssociationsForCodeSystemEntityVersionId1(null);
             }
             }
             else
             {
             csev.setCodeSystemEntityVersionAssociationsForCodeSystemEntityVersionId1(null);
             }
             csev.setCodeSystemEntityVersionAssociationsForCodeSystemEntityVersionId2(null);
             }
                    
             csev.setCodeSystemMetadataValues(null);
             csev.setConceptValueSetMemberships(null);
             csev.setPropertyVersions(null);
             csev.setAssociationTypes(null);
                    
             csc.setCodeSystemEntityVersion(null);
                    
             logger.debug("Akt Code: " + csc.getCode() + ", " + csc.getTerm());
                    
             //Translations
             if (csc.getCodeSystemConceptTranslations() != null)
             {
             Iterator<CodeSystemConceptTranslation> itTrans = csc.getCodeSystemConceptTranslations().iterator();
                    
             while (itTrans.hasNext())
             {
             CodeSystemConceptTranslation csct = itTrans.next();
             csct.setCodeSystemConcept(null);
             }
             }
                    
                    
                    
             csev.setCodeSystemConcepts(new HashSet<CodeSystemConcept>());
             csev.getCodeSystemConcepts().add(csc);
                    
             entity.setCodeSystemEntityVersions(new HashSet<CodeSystemEntityVersion>());
             entity.getCodeSystemEntityVersions().add(csev);
                    
             // M:N Verbindung zur Vokabular-Version (ohne nachladen)
             CodeSystemVersionEntityMembership ms = (CodeSystemVersionEntityMembership) entity.getCodeSystemVersionEntityMemberships().toArray()[0];
             ms.setCodeSystemVersion(null);
             ms.setCodeSystemEntity(null);
             ms.setId(null);
                    
             entity.setCodeSystemVersionEntityMemberships(new HashSet<CodeSystemVersionEntityMembership>());
             entity.getCodeSystemVersionEntityMemberships().add(ms);
                    
             entityList.add(entity);
             }
             }
             catch (org.hibernate.exception.GenericJDBCException ex)
             {
             logger.debug("Keine Eintraege");
             ex.printStackTrace();
             }
                    
             int anzahl = 0;
             if (entityList != null)
             anzahl = entityList.size();
             response.setCodeSystemEntity(entityList);
                    
             // Treffermenge prfen
             if (anzahlGesamt > anzahl)
             {
             // Paging wird aktiviert
             response.setPagingInfos(new PagingResultType());
             response.getPagingInfos().setMaxPageSize(maxPageSize);
             response.getPagingInfos().setPageIndex(pageIndex);
             response.getPagingInfos().setPageSize(pageSize);
             response.getPagingInfos().setCount((int) anzahlGesamt);
             if (parameter != null && parameter.getPagingParameter() != null)
             {
             response.getPagingInfos().setMessage("Paging wurde aktiviert, da die Treffermenge grer ist als die maximale Seitengre.");
             }
             //response.getPagingInfos().setMessage();
             }
             //response.setPagingInfos(null);
                    
             // Status an den Aufrufer weitergeben
             response.getReturnInfos().setOverallErrorCategory(ReturnType.OverallErrorCategory.INFO);
             response.getReturnInfos().setStatus(ReturnType.Status.OK);
             response.getReturnInfos().setMessage("Konzepte erfolgreich gelesen, Anzahl: " + anzahl);
             response.getReturnInfos().setCount(anzahl);
                    
             }
             }
             else
             {
             response.setCodeSystemEntity(new LinkedList<CodeSystemEntity>());
             response.getReturnInfos().setOverallErrorCategory(ReturnType.OverallErrorCategory.INFO);
             response.getReturnInfos().setStatus(ReturnType.Status.OK);
             response.getReturnInfos().setMessage("Keine Konzepte fr die Filterkriterien vorhanden");
             response.getReturnInfos().setCount(0);
             }*/
            // Hibernate-Block wird in 'finally' geschlossen, erst danach
            // Auswertung der Daten
            // Achtung: hiernach knnen keine Tabellen/Daten mehr nachgeladen werden
            //if(createHibernateSession)
            //hb_session.getTransaction().commit();
        } catch (Exception e) {
            //if(createHibernateSession)
            //hb_session.getTransaction().rollback();
            // Fehlermeldung an den Aufrufer weiterleiten
            response.getReturnInfos().setOverallErrorCategory(ReturnType.OverallErrorCategory.ERROR);
            response.getReturnInfos().setStatus(ReturnType.Status.FAILURE);
            response.getReturnInfos()
                    .setMessage("Fehler bei 'ListCodeSystemConcepts', Hibernate: " + e.getLocalizedMessage());

            LoggingOutput.outputException(e, this);
        } finally {
            // Transaktion abschlieen
            if (createHibernateSession) {
                hb_session.close();
            }
        }

    } catch (Exception e) {
        // Fehlermeldung an den Aufrufer weiterleiten
        response.getReturnInfos().setOverallErrorCategory(ReturnType.OverallErrorCategory.ERROR);
        response.getReturnInfos().setStatus(ReturnType.Status.FAILURE);
        response.getReturnInfos().setMessage("Fehler bei 'ListCodeSystemConcepts': " + e.getLocalizedMessage());

        LoggingOutput.outputException(e, this);
    }

    return response;
}

From source file:de.fhg.fokus.hss.db.op.CxEvents_DAO.java

License:Open Source License

public static void delete(Session session, int grp) {
    Query query = session.createSQLQuery("delete from cx_events where grp=?");
    query.setLong(0, grp);
    query.executeUpdate();//from   w  ww. ja v  a 2 s .co  m
}

From source file:de.fhg.fokus.hss.db.op.CxEvents_DAO.java

License:Open Source License

public static void delete(Session session, long hopbyhop, long endtoend) {
    Query query = session.createSQLQuery("delete from cx_events where hopbyhop=? and endtoend=?");
    query.setLong(0, hopbyhop);
    query.setLong(1, endtoend);// ww w .  j a va2s  . c  o m
    query.executeUpdate();
}

From source file:de.fhg.fokus.hss.db.op.CxEvents_DAO.java

License:Open Source License

public static List get_all_IMPI_IDs_by_HopByHop_and_EndToEnd_ID(Session session, long hopbyhop, long endtoend) {
    Query query;
    query = session.createSQLQuery("select distinct id_impi from cx_events where hopbyhop=? and endtoend=?")
            .addScalar("id_impi", Hibernate.INTEGER);
    query.setLong(0, hopbyhop);
    query.setLong(1, endtoend);//from   w w  w  .  j  ava2s  . c om
    return query.list();
}

From source file:de.fhg.fokus.hss.db.op.CxEvents_DAO.java

License:Open Source License

public static CxEvents get_one_from_grp(Session session, long hopbyhop, long endtoend) {
    Query query;
    query = session.createSQLQuery("select * from cx_events where hopbyhop=? and endtoend=? limit 1")
            .addEntity(CxEvents.class);
    query.setLong(0, hopbyhop);
    query.setLong(1, endtoend);/*from  w w w. ja  v  a  2s  .  c  om*/
    return (CxEvents) query.uniqueResult();
}

From source file:de.fhg.fokus.hss.db.op.ShNotification_DAO.java

License:Open Source License

public static ShNotification get_one_from_grp(Session session, int grp) {
    Query query;
    query = session.createSQLQuery("select * from sh_notification where grp=? limit 1")
            .addEntity(ShNotification.class);
    query.setLong(0, grp);
    return (ShNotification) query.uniqueResult();
}

From source file:de.fhg.fokus.hss.db.op.ShNotification_DAO.java

License:Open Source License

public static void delete(Session session, long hopbyhop, long endtoend) {
    Query query = session.createSQLQuery("delete from sh_notification where hopbyhop=? and endtoend=?");
    query.setLong(0, hopbyhop);
    query.setLong(1, endtoend);//from ww w  .jav a2  s.  c o  m
    query.executeUpdate();
}

From source file:de.iew.framework.persistence.hibernate.HbmTreeOperationDaoImpl.java

License:Apache License

public void incNestedSetBorders(long treeId) {
    String hql = "UPDATE Node SET nestedSetLeft = nestedSetLeft + 1, nestedSetRight = nestedSetRight + 1 WHERE tree.id = :treeId";

    Query query = getCurrentSession().createQuery(hql);
    query.setLong("treeId", treeId);

    int updated = query.executeUpdate();
    if (log.isDebugEnabled()) {
        log.debug("Es wurden " + updated + " Knoten aktualisiert.");
    }/*w ww . j av  a2  s.  co m*/
}

From source file:de.iew.framework.persistence.hibernate.HbmTreeOperationDaoImpl.java

License:Apache License

public void moveNestedSetBorder(long treeId, long fromNestedSetIndex) {
    String hql = "UPDATE Node SET nestedSetRight = nestedSetRight + 2 WHERE tree.id = :treeId AND nestedSetRight > :fromNestedSetIndex";
    Query query = getCurrentSession().createQuery(hql);
    query.setLong("treeId", treeId);
    query.setLong("fromNestedSetIndex", fromNestedSetIndex);

    int update = query.executeUpdate();
    if (log.isDebugEnabled()) {
        log.debug("Es wurde, fr " + update + " Knoten, der nestedSetRight Wert aktualisiert.");
    }//from ww w  . ja v a  2 s.c  om

    hql = "UPDATE Node SET nestedSetLeft = nestedSetLeft + 2 WHERE tree.id = :treeId AND nestedSetLeft > :fromNestedSetIndex";
    query = getCurrentSession().createQuery(hql);
    query.setLong("treeId", treeId);
    query.setLong("fromNestedSetIndex", fromNestedSetIndex);

    update = query.executeUpdate();
    if (log.isDebugEnabled()) {
        log.debug("Es wurde, fr " + update + " Knoten, der nestedSetLeft Wert aktualisiert.");
    }
}

From source file:de.iew.framework.persistence.hibernate.HbmTreeOperationDaoImpl.java

License:Apache License

public void deleteSingleNode(long treeId, long nodeId) {
    Node nodeToDelete = findNodeForTreeAndId(treeId, nodeId);
    if (nodeToDelete == null) {
        return;//w ww  .  j  a  v a 2 s  . c  o m
    }

    long leftNestedSetIndex = nodeToDelete.getNestedSetLeft();
    long rightNestedSetIndex = nodeToDelete.getNestedSetRight();

    this.nodeDao.remove(nodeToDelete);

    Session session = getCurrentSession();

    String hql;
    Query query;
    int update;

    hql = "UPDATE Node SET nestedSetLeft = nestedSetLeft - 1, nestedSetRight = nestedSetRight - 1 WHERE tree.id = :treeId AND nestedSetLeft BETWEEN :leftNestedSetIndex AND :rightNestedSetIndex";
    query = session.createQuery(hql);
    query.setLong("treeId", treeId);
    query.setLong("leftNestedSetIndex", leftNestedSetIndex);
    query.setLong("rightNestedSetIndex", rightNestedSetIndex);
    update = query.executeUpdate();
    if (log.isDebugEnabled()) {
        log.debug("Es wurde, fr " + update
                + " Knoten, die nestedSetLeft und nestedSetRight Eigenschaft aktualisiert.");
    }

    long delta = 2;
    updateNestedSetIndexImpl(treeId, delta, rightNestedSetIndex);
}