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>
This comment has been removed by the author.
ReplyDeleteafter i did NotFoundAction.IGNORE teh same error happends does any one know
ReplyDeleteCheck all columns that have foreign key relationship
ReplyDeletebut 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"
ReplyDeleteYour new exception tell us that Hibernate cannot save the child object because the exactly same object has been already deleted before.
ReplyDeleteThis 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 !
ReplyDeleteit helped me
ReplyDeletethank you very much, I had this error for so many hours...
ReplyDeleteGreat! Saved my time.
ReplyDeleteThank you... this was very helpful
ReplyDeleteThanks, very helpful
ReplyDeleteGreat..It saced my time..Thanks
ReplyDeleteDude, You are my hero!
ReplyDeletenot-found="ignore" - save my day!
Thanks a lot.. You saved my time.. :)
ReplyDeleteThanks a lot it was helpfull!!!!
ReplyDeleteThanks Man! great help.
ReplyDelete