-->
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.  [ 3 posts ] 
Author Message
 Post subject: Statement Problem
PostPosted: Thu Feb 08, 2007 4:51 pm 
Newbie

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 10
Location: Buenos Aires
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.2

Mapping documents:
Seccion mapping

<list name="avisos" table="AVISO" cascade="all,delete-orphan" inverse="false">
<key column="SECCION_ID" not-null="true" ></key>
<list-index column="ORDEN" ></list-index>
<one-to-many class="com.sae.model.mya.Aviso"/>
</list>

Aviso mapping

<many-to-one name="seccion" column="SECCION_ID"
not-null="true" insert="false" update="false"></many-to-one>

Full stack trace of any exception that occurs:

java.lang.NullPointerException
oracle.jdbc.driver.OracleStatement.describe(OracleStatement.java:6442)
oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java:6206)
oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1557)
oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1543)
org.hibernate.type.StringType.get(StringType.java:18)
org.hibernate.type.NullableType.nullSafeGet(NullableType.java:113)
com.sae.arquitectura.dao.common.converter.ObjectIdConverter.nullSafeGet(ObjectIdConverter.java:73)
org.hibernate.type.CustomType.nullSafeGet(CustomType.java:105)
org.hibernate.type.ManyToOneType.hydrate(ManyToOneType.java:103)
org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2046)
org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1371)
org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1299)
org.hibernate.loader.Loader.getRow(Loader.java:1197)
org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:568)
org.hibernate.loader.Loader.doQuery(Loader.java:689)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
org.hibernate.loader.Loader.loadCollection(Loader.java:1985)
org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
org.hibernate.collection.PersistentList.toArray(PersistentList.java:123)
java.util.ArrayList.addAll(ArrayList.java:434)
com.sae.model.mya.Seccion.getSortedAvisos(Seccion.java:123)
com.sae.webapp.action.mya.AvisoAction.list(AvisoAction.java:66)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:278)
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:218)
com.sae.arquitectura.webapp.struts.BaseDispatchAction.execute(BaseDispatchAction.java:206)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:465)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:505)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:172)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)



Name and version of the database you are using:
Oracle 9i

The generated SQL (show_sql=true):

Hibernate:
select
tipopriori0_.TIPO_ID as id0_,
tipopriori0_1_.version as version0_,
tipopriori0_1_.codigoInterno as codigoIn3_0_,
tipopriori0_1_.descripcion as descripc4_0_,
tipopriori0_1_.nombre as nombre0_,
tipopriori0_1_.SUPER_TIPO_ID as SUPER6_0_,
tipopriori0_1_.fechaCreacion as fechaCre7_0_,
tipopriori0_1_.fechaModificacion as fechaMod8_0_,
tipopriori0_.nivelPrioridad as nivelPri2_1_
from
TIPOPRIORIDAD tipopriori0_,
TIPO tipopriori0_1_
where
tipopriori0_.TIPO_ID=tipopriori0_1_.id
and (
(
tipopriori0_1_.codigoInterno=4798
)
)
Hibernate:
select
avisos0_.SECCION_ID as SECCION2_1_,
avisos0_.id as id1_,
avisos0_.ORDEN as ORDEN1_,
avisos0_.id as id28_0_,
avisos0_.SECCION_ID as SECCION2_28_0_,
avisos0_.fechaDesde as fechaDesde28_0_,
avisos0_.fechaHasta as fechaHasta28_0_,
avisos0_.mensaje as mensaje28_0_,
avisos0_.PRIORIDAD_ID as PRIORIDAD6_28_0_,
avisos0_.titulo as titulo28_0_,
avisos0_.fechaCreacion as fechaCre8_28_0_,
avisos0_.fechaModificacion as fechaMod9_28_0_
from
AVISO avisos0_
where
avisos0_.SECCION_ID=?
08-feb-2007 17:38:58 INFO StringType:128 - could not read column value from result set: SECCION2_28_0_; null
08-feb-2007 17:38:58 WARN RequestProcessor:519 - Unhandled Exception thrown: class java.lang.NullPointerException

Debug level Hibernate log excerpt:

I ´ve been working with this al least for 3 days.

when hibernate try to get a property from the resul Set, that value isn´t there and then a null pointer exception is thrown. If I inspect the Result set with the debugger, the query is the same as hibernate generate above and the value seccion2_28_0 is in the resul set into a property call m_originalSQL.
I migrate Hibernate 2 to 3.2 and I suspect this issue could be related with the hibernate configuration:

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
com.sae.arquitectura.database.oracle.dialect.OracleDialect
</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.region_prefix">hibernate.test</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.connection.provider_class">org.hibernate.connection.ProxoolConnectionProvider</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.jdbc.batch_versioned_data">false</prop>
<prop key="hibernate.jdbc.use_streams_for_binary">true</prop>
<prop key="hibernate.hbm2ddl.auto">validate</prop>
<prop key="hibernate.max_fetch_depth">2</prop>
<prop key="hibernate.jdbc.batch_size">10</prop>

<prop key="hibernate.proxool.pool_alias">sae</prop>
<prop key="hibernate.proxool.properties">proxool.properties</prop>
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
<prop key="hibernate.query.substitutions">true 1, false 0, yes 'Y', no 'N'</prop>
</props>
</property>
</bean>

Do you have any idea of this?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 09, 2007 12:44 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi ariel leinvand,

Might be session id in child table is null
<many-to-one name="seccion" column="SECCION_ID"
not-null="true" insert="false" update="false"></many-to-one>

Plz.. check it

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 09, 2007 8:59 am 
Newbie

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 10
Location: Buenos Aires
dharmendra.pandey wrote:
Hi ariel leinvand,

Might be session id in child table is null
<many-to-one name="seccion" column="SECCION_ID"
not-null="true" insert="false" update="false"></many-to-one>

Plz.. check it


Thanks for the response.

I have not-null in the mapping.

Finally I ´ve made it work.

In my Java code I have this:

public class Seccion

public Seccion(){
/*Por default una nueva seccion pasa a estar primera*/
// this.setOrden(new Double(0));
// this.setPrioridad((TipoPrioridad)Locator.getPrioridadService().getPrioridadBy(Constants.PRIORIDAD_MEDIA));
};

public void addAviso(int pos, Aviso unAviso) {
log.debug("Ejecutando addAviso()");
if(unAviso != null && !this.getAvisos().contains(unAviso)){
this.avisos.add(pos, unAviso);
unAviso.setSeccion(this);
}
log.debug("Finalizada la ejecucion de addAviso()");
}

public class Aviso

public Aviso(){
/*Por default una nuevo aviso pasa a estar primera*/
//this.setPrioridad((TipoPrioridad)Locator.getPrioridadService().getPrioridadBy(Constants.PRIORIDAD_MEDIA));

};

/**
* @hibernate.many-to-one column="SECCION_ID" not-null="true" insert="false" update="false" access="field"
*/
public Seccion getSeccion(){
return this.seccion;
}
public void setSeccion(Seccion seccion) {
this.seccion = seccion;
if(seccion!=null)
seccion.addAviso(this);

}

I don´t know why, but I need to take care of the default constructor don´t make an access to DB.

and another thing that I did is put access="field" to the property seccion of Aviso.

another change was make the collection of avisos lazy=false, because when i display all the sections i need to display all the advice. anyway I´ll try what happen with lazy="true"


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.