Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EntityNotFound Esxception or Null values ?
EntityNotFound Esxception or Null values ? [message #1758918] Tue, 04 April 2017 15:06 Go to next message
Raffaele Esposito is currently offline Raffaele EspositoFriend
Messages: 2
Registered: April 2017
Junior Member

Under the hood a persistence Provider like EclipseLink or Hibernate uses find() or getReference() to load entities when we call getter methods of a ManyToOne annotated field?

find() returns null if EntityNotFound

getReference() throws an EntityNotFoundException

So what should getters do in the case the Entity is not found when when we are navigating relations ?
Re: EntityNotFound Esxception or Null values ? [message #1758969 is a reply to message #1758918] Tue, 04 April 2017 20:41 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
If there is no referenced entity, the model will return null.
Re: EntityNotFound Esxception or Null values ? [message #1758971 is a reply to message #1758969] Tue, 04 April 2017 20:50 Go to previous messageGo to next message
Raffaele Esposito is currently offline Raffaele EspositoFriend
Messages: 2
Registered: April 2017
Junior Member
Hi chris,Thanks for your time.
Yeah I know that this is the default behaviour in EclipseLink,
and in Hibernate according to the default behaviour an Exception of class EntityNotFoundException is raised, right ?

So this means that the spec (i.e. JPA) does not say anything about what the standard behaviour should be in such cases, right ?

[Updated on: Tue, 04 April 2017 20:51]

Report message to a moderator

Re: EntityNotFound Esxception or Null values ? [message #1759060 is a reply to message #1758971] Wed, 05 April 2017 16:28 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
I don't know why another provider would throw an exception when traversing your object model as I would expect the behavior to be the same regardless of the fetch type, but the JPA spec does not seem to cover the behavior when a foreign key references a non-existing row.
Previous Topic:BatchFetch examples?
Next Topic:QueryException: Modify queries require an object to modify, InsertObjectQuery(null)
Goto Forum:
  


Current Time: Sat Apr 27 02:35:18 GMT 2024

Powered by FUDForum. Page generated in 0.03481 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top