Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to avoid returng null object after deleting an object from the list collection?

 
how jee
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Hibernate's experts,

I got an issue with returning a null when retrieving a LIST collection (after deleting one). For example :

(1) partsList is a LIST collection, which has <list-index column="position">

<class name="Whole">
<id name="id" column="whole_id" >
<generator class="native"/>
</id>
<list name="partsList" cascade="all-delete-orphan">
<key column="whole_id" not-null="true"/>
<list-index column="position"/>
<one-to-many class="Part"/>
</list>
<property name="name"/> <!-- for example -->
</class>

(2) After inserting 3 rows for partsList, in database table, I can see that there are values 0, 1, 2 in the "position" column.

(3) Then I use hibernate delete the middle row, which has position value 1. So the entries with position value 0 and 1 remain.

(4) When I retrieve the "Whole" object with "partsList", I still get 3 entry back for "partsList", among which the second one is null.

Has anybody encountered this situation, is there any way to avoid getting the null entry?

Thanks!

J
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could it be related to the caching?

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic