Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointerException while trying to access the entity's particular field

 
yuvaraj KumarAmudhan
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I have a table (BaseInfo) which has four fields called Id(primary key), Name, Age and Type. In this, "Type" field is Bigint datatype and it can hold 1 or 2 or null as value.
I have some another table (AdInfo) which refers the BaseInfo's Type field.

I inserted a record in BaseInfo table with the values (1, x, 28, (null)).

I can get the BaseInfo object by finding a record with the primary key "1" with the statement (em.find(BaseInfo.class, 1)).
And also i can print the values of that object except the "Type's value".

System.out.print(BaseInfoObj.getName()); --- Prints the value
System.out.print(BaseInfoObj.getAge()); ---- Prints the value

System.out.print(BaseInfoObj.getType()); ---- prints
javax.ejb.EJBException: java.lang.NullPointerException
ERROR [STDERR] at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:77)
ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
ERROR [STDERR] at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

Any idea regarding this?

Thank you!


 
yuvaraj KumarAmudhan
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody having any idea about this?

This might be the basic thing but i don't know how to resolve this.
 
Palash Nandi
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi yuvaraj,
What kind of object is BaseInfoObj, does it have other references inside it, because as as shown by the previous statements its reference cannot be null. I think the method BaseInfoObj.getType() in internally calling some method of another internal reference object inside BaseInfoObj which is null.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And please post the entire exception stacktrace.
 
yuvaraj KumarAmudhan
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replies. Just now i found the problem (Casting). Fixed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic