Link to home
Start Free TrialLog in
Avatar of prsubject
prsubjectFlag for India

asked on

Nullpointer exception Hibernate

When I run a hibernate code I am getting the following exception. Need help please.

java.lang.NullPointerException
      at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)
      at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121)
      at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232)
      at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173)
      at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
      at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:869)
      at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:838)
      at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
      at org.hibernate.type.EntityType.resolve(EntityType.java:303)
      at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
      at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
      at org.hibernate.loader.Loader.doQuery(Loader.java:717)
      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
      at org.hibernate.loader.Loader.doList(Loader.java:2150)
      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
      at org.hibernate.loader.Loader.list(Loader.java:2024)
      at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:369)
      at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:300)
      at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:146)
      at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1093)
      at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
      at com.twc.soatest.dao.DigitalPhoneDAO.validateDPActivation(DigitalPhoneDAO.java:296)
      at com.twc.soatest.db.SOATestDBUtil.validateDPActivation(SOATestDBUtil.java:275)
      at com.twc.soatest.db.TestSOATest.main(TestSOATest.java:27)
Avatar of prsubject
prsubject
Flag of India image

ASKER

Some say to move from cglib to javaassist. I am having both
Avatar of Gurvinder Pal Singh
can you post the following code also.
validateDPActivation method in DigitalPhoneDAO class
public boolean validateDPActivation(String tn, Session session)
    {
        Application.showMessage("Entering validateDPActivation - DigitalPhoneDAO");
        Application.showMessage("TN retrieved from DB is "+tn);
        boolean dpActivated=false;
        List<ServiceProfile> spList = new ArrayList<ServiceProfile>();
        ServiceProfile sProfile = null;
        try {
        Query query = session.getNamedQuery("com.xxx.soatest.bsif.entity.ServiceProfile.getServiceProfileByTN");
        query.setString("tn", tn);
        spList=query.list();
       
        Application.showMessage("From DAO List size is "+spList.size());
       
       
            for(int index=0; index<spList.size();index++)
            {
                sProfile= (ServiceProfile) spList.get(index);
            }
            /*if(spList.size() > 0)
                dpActivated=true;*/
            if(sProfile!= null && sProfile.getServiceUid().equals(tn))
                dpActivated=true;
        }
        catch(Exception e) {
            e.printStackTrace();
        }
        finally {
            session.close();
        }
        Application.showMessage("From DAO List size is "+spList.size());
        System.out.println("From DAO List size is "+spList.size());
        Application.showMessage("Inside DAO class is DPActivated "+dpActivated);
        return dpActivated;
    }
I am getting list size as 0 even if data exists
From DAO List size is 0
TN Exists false

This is my query in hbm.xml file
        <query name="getServiceProfileByTN">
            <![CDATA[FROM  ServiceProfile a WHERE  a.serviceUid= :tn]]>
        </query>


ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
select * from xxx sp
where sp.yyy='5124349071' is giving a record
I downloaded the hqe The bat file is not opening up. It is displaying some error and closing

I need to show the results today. need help please.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@prsubject: if you need help in getting this cross-checked, please post the code here, i can help in that. Or let me know if any reference is required.

Also please check, if the value you are testing with is the same value which is getting passed to the query also and to the correct column.