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.  [ 7 posts ] 
Author Message
 Post subject: Question about PropertyValueException
PostPosted: Thu Mar 30, 2006 4:32 am 
Newbie

Joined: Wed Mar 29, 2006 6:56 am
Posts: 4
Hello everybody,

I have strange problem with hibernate, maybe it's easy to solve, but I don't have any idea how. Sometimes when I retrieve values from DB through hibernate I got PropertyValueException. Here is the log :

Caused by: org.hibernate.PropertyValueException: not-null property references a null or transient value: com.test.jaxb.impl.ChangeRequestItemImpl.amendmentText
at org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:163)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:190)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:70)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:39)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:656)
at org.hibernate.impl.SessionImpl.prepareQueries(SessionImpl.java:832)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:822)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:779)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at com.test.ChangeRequestService.getChangeRequestList(ChangeRequestService.java:831)

What is the strange for me, that this error occurs when reading data from DB ( see the functions - getChnangeRequestList ) and in DB are all datas correct.

Maybe this is result of previous error and the hibernate session hasn't been correctly closed, but I'm not sure if my hypothesis is correct.

Please if anybode has some idea, help me.

Thank you very much.

John


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 4:54 am 
Newbie

Joined: Wed Mar 01, 2006 4:14 am
Posts: 16
give us the hibernate mapping and java class concerning this property :)


maybe in the database the property is null and in the mapping it is set to not-null="true"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 6:09 am 
Newbie

Joined: Wed Mar 29, 2006 6:56 am
Posts: 4
yes, you are right, the mapping property com.test.jaxb.impl.ChangeRequestItemImpl.amendmentText is set to not-null="true", but DB is mapping column also set NOT NULL and all datas in DB are correct.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 4:08 am 
Newbie

Joined: Wed Mar 01, 2006 4:14 am
Posts: 16
can you give the code from the function, com.test.jaxb.impl.ChangeRequestItemImpl.amendmentText , the function com.test.ChangeRequestService.getChangeRequestList, and the mapping of the classes which are relevant for this problem

I had this problem before but without some more code and mappings, I can't help you


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 10:31 am 
Newbie

Joined: Wed Mar 29, 2006 6:56 am
Posts: 4
Here is part of mapping file :

<hibernate-mapping>
<class name="com.test.jaxb.impl.ChangeRequestImpl" table="SCHNG_REQ" entity-name="ChangeRequestFull">
<id name="id" type="integer" unsaved-value="0">
<column name="CHNG_REQ_ID" not-null="true"/>
<generator class="native">
<param name="sequence">SQ_SCHNG_REQ</param>
</generator>
</id>
<property name="receivedDate" type="calendar">
<column name="RECEIVED_DATE" sql-type="date" not-null="true"/>
</property>
<array name="item" inverse="true" cascade="all" fetch="select">
<key column="CHNG_REQ_ID" not-null="true" on-delete="cascade"/>
<list-index column="SEQ_NR"/>
<one-to-many class="com.test.jaxb.impl.ChangeRequestItemImpl"/>
</array>
</class>
<class name="com.test.jaxb.impl.ChangeRequestItemImpl" table="SCHNG_REQ_ITEM">
<id name="id" type="integer" unsaved-value="0">
<column name="CHNG_REQ_ITEM_ID" not-null="true"/>
<generator class="native">
<param name="sequence">SQ_SCHNG_REQ_ITEM</param>
</generator>
</id>
<property name="sequenceNumber" type="short">
<column name="SEQ_NR" not-null="true"/>
</property>
<property name="amendmentText" type="string">
<column name="AMDT_TEXT" length="4000" not-null="true"/>
</property>
<property name="validFrom" type="calendar">
<column name="VALID_FROM" not-null="true"/>
</property>
<property name="userId" type="integer">
<column name="USER_ID" not-null="true"/>
</property>
<many-to-one name="changeRequest" class="ChangeRequestFull" column="CHNG_REQ_ID" not-null="true"/>
</array>
</class>

And the function where error occurs:

public String getChangeRequestList()
throws Exception
{
String xml = null;
try {

ApplicationUser applicationUser = this.getApplicationUser();

Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();

com.test.jaxb.ObjectFactory objFact = new com.test.jaxb.ObjectFactory();

Query query = session.createQuery( getQueryString() );

List requestList = query.list();
prepareChngRequestsToSend( requestList, session );

com.test.jaxb.ChangeRequestDataSet ds = objFact.createChangeRequestDataSet();
com.test.jaxb.ChangeRequest[] array = new com.test.jaxb.ChangeRequest[requestList.size()];

ChangeRequest[] chngReqArray = (com.test.jaxb.ChangeRequest[]) requestList.toArray(array);
ds.setChangeRequest( chngReqArray );

xml = marshalDataSet(ds);

tx.commit();
HibernateUtil.closeSession();
}
catch (HibernateException ex) {
ex.printStackTrace();
throw ex;
}
catch (JAXBException ex) {
ex.printStackTrace();
throw ex;
}
return xml;
}


And my main question is still the same :
How can I get org.hibernate.PropertyValueException when I'm retrieving information from DB and in DB are datas correct ?

Thank you for any advice and ideas.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 03, 2006 3:56 am 
Newbie

Joined: Wed Mar 01, 2006 4:14 am
Posts: 16
mapping looks ok

the getquerystring probably builds the select for retrieving the object
where do you use the property amendmenttext, try getAmendmentText () before closing the session/transaction, the text is a clob or something in the database not?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 05, 2006 4:23 am 
Newbie

Joined: Wed Mar 29, 2006 6:56 am
Posts: 4
Thanks jurgendl for your ideas. I think I found solution.
Because I can't repeat orignal error, I only simulate it - I set property amedmentText to null and try to save it. As result runtime exception PropertyValueException is thrown. When you don't close hibernate session in this case, in next command this exception appears again.

So when next command is retrieve data from DB, you get this ( at first look unusal ) exception, because hibernate tries to finish save action.

I hope that I'm correct. :)


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