Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: HibernateObjectRetrievalFailureExceptio with notnull="f
PostPosted: Thu Feb 03, 2005 5:29 pm 
Beginner
Beginner

Joined: Thu Jan 20, 2005 3:25 pm
Posts: 22
I have strange problem with many-to-one. On "caracteristiques", not-null is set to "false". So shouldn't I get null instead of org.hibernate.ObjectNotFoundException?


Hibernate version:
3.0beta3

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping>
<class
name="actualis.web.bo.catalogue.ValeurCaracteristique"
table="valeurs_caracteristiques"
>
<id
name="id"
type="java.lang.Integer"
column="id"
>
<generator class="assigned" />
</id>

<property
name="idCar"
type="int"
column="id_car"
not-null="true"
unique="true"
insert="false"
update="false"
length="10"
>
</property>
<property
name="refArticle"
type="java.lang.String"
column="ref_article"
not-null="true"
unique="true"
insert="false"
update="false"
length="18"
>
</property>
<property
name="valBool"
type="boolean"
column="val_bool"
>
</property>
<property
name="valTxt"
type="java.lang.String"
column="val_txt"
unique="true"
length="255"
>
</property>
<property
name="valNum"
type="java.lang.Double"
column="val_num"
length="22"
>
</property>

<!-- Associations -->
<many-to-one
name="article"
class="actualis.web.bo.catalogue.Article"
not-null="true"
>
<column name="ref_article" />
</many-to-one>
<many-to-one
name="caracteristique"
class="actualis.web.bo.catalogue.Caracteristique"
not-null="false"
>
<column name="id_car" />
</many-to-one>

</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Excerpt from ProduitsDAO
public Set getCaracteristiquesArticle(Article ar) {
Set cars = ar.getValeursCaracteristiques();
Set carsvs = new TreeSet();
for (Iterator it = cars.iterator(); it.hasNext();) {
ValeurCaracteristique vc = (ValeurCaracteristique) it.next();
if (!vc.getCaracteristique().isCache()) { <- that is line 72
CaracteristiqueArticle ca = new CaracteristiqueArticle();
ca.setIntitule(vc.getCaracteristique().getNom());
ca.setValeur(getDisplayValeurCaracteristique(vc));
carsvs.add(ca);
}
}
return carsvs;
}
Full stack trace of any exception that occurs:
Stack Trace:

* org.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:27)
* org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:739)
* org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:59)
* org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80)
* org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:115)
* actualis.web.bo.catalogue.Caracteristique$$EnhancerByCGLIB$$b4c86871.isCache(<generated>)
* actualis.web.dao.ProduitsDAO.getCaracteristiquesArticle(ProduitsDAO.java:72)
* actualis.web.spring.WebManager.getCaracteristiquesArticle(WebManager.java:91)
* actualis.web.spring.WebManager$$FastClassByCGLIB$$f2fb6e0a.invoke(<generated>)
* net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
* org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:676)
* org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
* org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:163)
* org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
* org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:619)
* actualis.web.spring.WebManager$$EnhancerByCGLIB$$6b4b8488.getCaracteristiquesArticle(<generated>)
* actualis.web.tapestry.pages.FicheArticle.activateExternalPage(FicheArticle.java:73)
* org.apache.tapestry.engine.ExternalService.service(ExternalService.java:161)
* org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:872)
* org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:197)
* org.apache.tapestry.ApplicationServlet.doGet(ApplicationServlet.java:158)
* javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
* javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
* org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
* org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
* org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:170)
* org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
* org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
* org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
* org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
* org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
* org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
* org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
* org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
* org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
* org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
* org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
* org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
* org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
* org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
* java.lang.Thread.run(Thread.java:595)

Name and version of the database you are using:
Mysql 4.1


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 03, 2005 5:31 pm 
Beginner
Beginner

Joined: Thu Jan 20, 2005 3:25 pm
Posts: 22
Forgot to add on the other end (Caracteristique), I have the following set:
<!-- bi-directional one-to-many association to Valeurs Caracteristiques -->
<set
name="valeursCaracteristiques"
lazy="true"
inverse="true"
>
<meta attribute="field-description">
@hibernate.set
lazy="true"
inverse="true"

@hibernate.collection-key
column="id_car"

@hibernate.collection-one-to-many
class="actualis.web.bo.catalogue.ValeurCaracteristique"
</meta>

<key>
<column name="id_car" />
</key>
<one-to-many
class="actualis.web.bo.catalogue.ValeurCaracteristique"
/>
</set>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 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.