When I execute my program without implementing hashcode()
and toString()
then it works fine. But as soon as I include hashcode()
and toString()
then I get this "illegal access to loading collection" error.
My hbm files are
1) booking.hbm.xml
<many-to-one name="userId" class="User" column="user_id"
insert="true" update="true" cascade="save-update" >
</many-to-one>
<many-to-one name="flightId" class="FlightSchedule"
column="flight_id" cascade="all" not-null="true">
</many-to-one>
<set name="passenger" table="passenger79215" lazy="false"
inverse="true" cascade="save-update">
<key column="reference_id" />
<one-to-many class="Passenger" />
</set>
2) Passenger.hbm.xml
<many-to-one name="referenceid" class="Booking" lazy="false"
insert="true" update="true" column="reference_id "
cascade="save-update">
</many-to-one>
3) User.hbm.xml
<set name="booking" table="bookings79215" lazy="true"
inverse="false" cascade="save-update">
<key column="user_id" />
<one-to-many class="Booking" />
</set>
Can anyone explain the error?
Your hashcode and equals methods are not working properly. Make sure that they are correct. toString()
has nothing to do with collection classes but hashcode and equals does.
I assume that you have overridden both hashcode and equals and not only hashcode.
Object#hashCode()
(Java Platform SE 7 )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With