SpringLearner
SpringLearner

Reputation: 13854

How to get username from a table

My Mysql table structure is like this

id category name

This is the way to show in jsp

<c:forEach items="${parentList}" var="test">
<ul style="max-width: 300px;" class="nav nav-pills nav-stacked">
  <li class="active"><a href="#" value="${test.id}-${test.category}" id="${parent.id}" onclick="return getQuestions(this);">
  <input type="checkbox" value="${test.id}">${test.name }</a></li>

    </ul>
</c:forEach>

parentList is obtained from the below method

List<Parent> parentList = 
                (List<Parent>)  serviceClientServiceImpl.getParents("Parent",Long.valueOf(clientId));

this is my serviceClientServiceImpl.getParents

public List<Parent> getParents(String entityName,Long clientId)
    {
        List<Parent> parentsList = null;
        try
        {
            parentsList = (List<Parent>) serviceClientDaoImpl.getParents(entityName,clientId);
        }
        catch(Exception e)
        {

        }
        return parentsList;
    }

and this is my serviceClientDaoImpl.getParents

public List<Parent> getParents(String entityName,Long cId)
    {
        String queryString="";
        queryString="select p FROM "+entityName+"p WHERE category=default or category=client and p.cid="+cId;
        Query query=entityManagerUtil.getQuery(queryString);
        query.setParameter("cId", cId);
        return query.getResultList();
    }

The problem is I do not see any thing in the html.So can any body tell me whats the mistake

Upvotes: 0

Views: 56

Answers (1)

conFusl
conFusl

Reputation: 939

Try it this way (varchars in ''):

select p FROM "+entityName+" p WHERE p.category='default' or p.category='client' and p.cid=" +cId";

Upvotes: 1

Related Questions