When there is a foreign key but the referenced row does not existed, or has been deleted, hibernate would throw an exception like this:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.firstwap.geofencing.pojo.VehicleGeofence#546]
at org.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:27)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:65)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:98)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:158)
at com.firstwap.geofencing.pojo.VehicleGeofence$$EnhancerByCGLIB$$3f798ceb.getGpsVehicle(<generated>)
at com.firstwap.geofencing.socket.GeofenceParser.setAlarmLog(GeofenceParser.java:409)
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.firstwap.geofencing.pojo.VehicleGeofence#546]
at org.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:27)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:65)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:98)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:158)
at com.firstwap.geofencing.pojo.VehicleGeofence$$EnhancerByCGLIB$$3f798ceb.getGpsVehicle(<generated>)
at com.firstwap.geofencing.socket.GeofenceParser.setAlarmLog(GeofenceParser.java:409)
If it's a bug, the code should handle this exception properly, either by marking the data as corrupted or notifying end-user about it.
If it's not a bug, setting the attribute not-found as "ignore" in the many-to-one hibernate mapping would eliminate the exception.<many-to-one name="employee" class="Employee"
column="CITY_ID" not-null="false" lazy="false" not-found="ignore">
</many-to-one>
16 comments: (+add yours?)
after i did NotFoundAction.IGNORE teh same error happends does any one know
Check all columns that have foreign key relationship
but my foreign key is compiste key based on two columns, i specifed as you mentioned but while updating is is giving Exception "deleted object is re-saved because there is an cascade asssciation"
Your new exception tell us that Hibernate cannot save the child object because the exactly same object has been already deleted before.
This condition usually happens when you accidentally removed (setting as null) the child object from the parent object and then set it again with the previous child object. You may try to read the code again to see which line has the condition, or try setting the mapping to cascade="none", but you will have to manually save each of the child objects.
this helped me a lot :-) thanks and keep up your good work !
it helped me
thank you very much, I had this error for so many hours...
Great! Saved my time.
Thank you... this was very helpful
Thanks, very helpful
Great..It saced my time..Thanks
Dude, You are my hero!
not-found="ignore" - save my day!
Thanks a lot.. You saved my time.. :)
Thanks a lot it was helpfull!!!!
Thanks Man! great help.
Post a Comment