hibernate composite-id returns null results

30 views Asked by At

Just before anyone down rate this question, I want to say i have tried to search an answer for this problem for 2 days now without any answers. I have tried a lot but could not resolve it so posting it here. I have created a view in mysql DB. Using hbm2hbmxml in maven I generated hbm and pojo files for this view. This is my code to query the view in mysql DB. Need to know why it is returning null.

    public List<VListingdetail> getListingDomainByUserId(int userId) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction transaction = null;
    List<VListingdetail> listingDomains = new ArrayList<VListingdetail>();
    try {
        transaction = session.beginTransaction();
        String whereClause = "from VListingdetail where primaryfile=1 and userId='" + userId + "'";
        Query result = session.createQuery(whereClause);
        List list = result.list();
        for (Iterator it = list.iterator(); it.hasNext();){
            listingDomains.add((VListingdetail)it.next());
        }
        transaction.commit();
    } catch (Exception e) {
        transaction.rollback();
        e.printStackTrace();
    } finally {
        session.close();
    }
    return listingDomains;
}

the results returns 3 rows but all of them are null enter image description here

Here is the screen shot of hbm file enter image description here

Here is the pojo file enter image description here

0

There are 0 answers