-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Many-to-one association throws NullPointerException
PostPosted: Wed Feb 22, 2006 5:44 am 
Newbie

Joined: Thu Feb 09, 2006 1:22 pm
Posts: 13
Location: Turkey
hi,

Here are the two related tables mappings :

<!-- HESAPPLAN -->
<class name="tr.com.usta.ITBMuhasebeOrtak.core.dvo.muhasebe.HesapPlan" table="U_HESAPPLANI">
<id name="hesapkod" column="HESAPKOD">
</id>
<property name="usthesapkod" column="USTHESAPKOD" length="30" not-null="false"/>
<property name="hesapad" column="HESAPAD" length="60" not-null="true"/>
<property name="detay" column="DETAY" length="1" not-null="true"/>
<property name="kirilimsayisi" type="integer" column="KIRILIMSAYISI" not-null="true"/>
<property name="seviye" column="SEVIYE" type="integer" not-null="true"/>
<property name="bilanco" column="BILANCO" length="5" not-null="true"/>
<property name="gelirtablosu" column="GELIRTABLOSU" length="1" not-null="true"/>
<property name="butce" column="BUTCE" length="1" not-null="true"/>
<property name="borcalacak" column="BORCALACAK" length="7" not-null="true"/>
<property name="demirbas" column="DEMIRBAS" length="1" not-null="true"/>
</class>

<!-- FISSATIR -->
<class name="tr.com.usta.ITBMuhasebeOrtak.core.dvo.muhasebe.FisSatir" table="U_FISSATIR">
<id name="fissatirkod" column="FISSATIRKOD">
</id>
<property name="fiskod" column="FISKOD" type="long" not-null="true"/>
<property name="detay" column="DETAY" length="1" not-null="true"/>
<property name="borc" column="BORC" type="double" not-null="true"/>
<property name="alacak" column="ALACAK" type="double" not-null="true"/>
<property name="dovizpbkod" column="DOVIZPBKOD" length="5" not-null="false"/>
<property name="dovizborc" type="double" column="DOVIZBORC" not-null="true"/>
<property name="dovizalacak" column="DOVIZALACAK" type="double" not-null="true"/>
<property name="aciklama" column="ACIKLAMA" length="500" not-null="false"/>
<property name="kurdeger" type="double" column="KURDEGER" not-null="true"/>
<property name="sirano" column="SIRANO" type="long" not-null="false"/>
<many-to-one name="hesapplan" column="HESAPKOD" class="tr.com.usta.ITBMuhasebeOrtak.core.dvo.muhasebe.HesapPlan" unique="true" not-null="true"/>
</class>

As you see in the last part of 'FISSATIR' i define the association relation. Through this, the column named as 'HESAPKOD' in 'FISSATIR' must be used to get the 'HesapPlan' object and set it to 'hesapplan' field of 'FisSatir' class.

When i run the application to get list of 'FISSATIR' the exception is below thrown :
/*******************************EXCEPTION******************/
java.lang.NullPointerException
at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntity
Tuplizer.java:372)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(Ab
stractEntityPersister.java:3121)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessa
ry(DefaultLoadEventListener.java:232)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultL
oadEventListener.java:173)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEv
entListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:889)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:857)
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.j
ava:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Lo
ader.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.ja
va:300)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java
:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1127)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at j2src.tr.com.usta.ITBMuhasebeServer.hibernate.util.HibernateUtil.extr
a(HibernateUtil.java:150)
at j2src.tr.com.usta.ITBMuhasebeServer.servlets.ProcessorServlet.doJobAn
dSetResult(ProcessorServlet.java:101)
at j2src.tr.com.usta.ITBMuhasebeServer.servlets.ProcessorServlet.doPost(
ProcessorServlet.java:57)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)

at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
rValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)

at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:15
2)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:683)
at java.lang.Thread.run(Thread.java:534)
/*******************************EXCEPTION******************/

I must indicate that every instance of 'FISSATIR' is initialized. So, what can you say?

_________________
eRoHaN


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2006 7:58 am 
Newbie

Joined: Thu Feb 09, 2006 1:22 pm
Posts: 13
Location: Turkey
no answer yet! I am suprised. I thought that it was a simple problem but it seems it is hard.

So must work more carefully...;)

_________________
eRoHaN


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 22, 2006 10:26 am 
Newbie

Joined: Tue Feb 21, 2006 4:03 pm
Posts: 10
Hi,

I have exactly the same problem.
(see my post of yesterday in this forum and in the german forum).

If I delete the association in the mapping it works.

What is your environment?

I use postgreSQL 8.0,
Hibernate 3.1.2
postgresql-8.0-314-jdbc2.jar
and Java 1.4.2-02

Tell me if you have success.

Ciao,
Rainer


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 23, 2006 5:31 am 
Newbie

Joined: Thu Feb 09, 2006 1:22 pm
Posts: 13
Location: Turkey
hi,

i must indicate that i get the result for 'FISSATIR' like this :

Code:
List list = theSession.createQuery(hqlQuery).list();


As you see here i give a query to get data. I expect hibernate to select from the table and update itself after the selection to set the 'HESAPPLAN' field that is aggregated in 'FISSATIR'. (Isn't it true?)

But hibernate does not work as i expect, because it was programmed to hold an instance of 'FISSATIR' or instance list of 'FISSATIR' in session and set the aggregated fields on it/them. So, if you have no object (i mean if 'FISSATIR' instance is null in session) it gives a "NullPointerException".

So, we must put it to session with 'session.load(...)' command. But here i have got a special case. The special case is this :

The 'FISKOD' field is related with a table named as 'U_FIS' and i try to get the 'FISSATIR' list through like a query : "from FisSatir where fiskod = 3451"

I EXPECT from HIBERNATE to LOAD the 'FISSATIR' list WHERE the 'fiskod' equals '3451' for example. While doing this, it must set the aggregated 'HesapPlan' field. Is the special cases are not supported?

Ignoring Hibernate Team here : Please give an acceptable answer. Because these type of requirements increases and there is another post about the same subject in forum also.

Regards,[/u]

_________________
eRoHaN


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 24, 2006 8:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
this is a *basic* many-to-one mapping that if it did not work we would not be able to run even the most basic hibernate tests.

reduce the problem and run it a simple junit tests instead of a full blown container....there must be more to this than what you show.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.