Nullpointer exception Hibernate

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

      at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(
      at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(
      at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(
      at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(
      at org.hibernate.event.def.DefaultLoadEventListener.onLoad(
      at org.hibernate.impl.SessionImpl.fireLoad(
      at org.hibernate.impl.SessionImpl.internalLoad(
      at org.hibernate.type.EntityType.resolveIdentifier(
      at org.hibernate.type.EntityType.resolve(
      at org.hibernate.engine.TwoPhaseLoad.initializeEntity(
      at org.hibernate.loader.Loader.initializeEntitiesAndCollections(
      at org.hibernate.loader.Loader.doQuery(
      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(
      at org.hibernate.loader.Loader.doList(
      at org.hibernate.loader.Loader.listIgnoreQueryCache(
      at org.hibernate.loader.Loader.list(
      at org.hibernate.loader.hql.QueryLoader.list(
      at org.hibernate.hql.ast.QueryTranslatorImpl.list(
      at org.hibernate.engine.query.HQLQueryPlan.performList(
      at org.hibernate.impl.SessionImpl.list(
      at org.hibernate.impl.QueryImpl.list(
      at com.twc.soatest.dao.DigitalPhoneDAO.validateDPActivation(
      at com.twc.soatest.db.SOATestDBUtil.validateDPActivation(
      at com.twc.soatest.db.TestSOATest.main(
Who is Participating?
Gurvinder Pal SinghConnect With a Mentor Commented:
For nullpointerexception while doing query.list(), please check if you have declared any nullable column as not-nullable in the mapping file.

<<I am getting list size as 0 even if data exists>>
Please check if the query that you are running (with the same substituted value) gives the same result when you run it independently
prsubjectAuthor Commented:
Some say to move from cglib to javaassist. I am having both
Gurvinder Pal SinghCommented:
can you post the following code also.
validateDPActivation method in DigitalPhoneDAO class
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

prsubjectAuthor Commented:
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("");
        query.setString("tn", tn);
        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)
            if(sProfile!= null && sProfile.getServiceUid().equals(tn))
        catch(Exception e) {
        finally {
        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;
prsubjectAuthor Commented:
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]]>

Gurvinder Pal SinghConnect With a Mentor Commented:
Use this hibernate query editor, it will save a lot of your time and points :)

it gives more detailed and informative error messages
prsubjectAuthor Commented:
select * from xxx sp
where sp.yyy='5124349071' is giving a record
prsubjectAuthor Commented:
I downloaded the hqe The bat file is not opening up. It is displaying some error and closing

prsubjectAuthor Commented:
I need to show the results today. need help please.
Gurvinder Pal SinghConnect With a Mentor Commented:
query.setString("tn", tn); is setting the tn value which is a integer value (from your reply #33594136), please make sure if the data type use here is the correct one as per your mapping
Gurvinder Pal SinghCommented:
@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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.