Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing EntityNotFoundException while calling getOne method [DATAJPA-1128] #1473

Closed
spring-projects-issues opened this issue Jun 7, 2017 · 3 comments
Assignees
Labels
in: core Issues in core support status: declined A suggestion or change that we don't feel we should currently apply type: bug A general bug

Comments

@spring-projects-issues
Copy link

Indra Basak opened DATAJPA-1128 and commented

EntityNotFoundException is expected while calling getOne method on JpaRepository. However in some instances, the exception is wrapped inside the entity instead of a thrown exception.

entity = {BookEntity_$$_jvst97c_0@9002} Method threw 'javax.persistence.EntityNotFoundException' exception. Cannot evaluate com.basaki.example.book.data.entity.BookEntity_$$_jvst97c_0.toString()
 handler = {JavassistLazyInitializer@9025} 
  interfaces = {Class[1]@9026} 
   0 = {Class@6374} "interface org.hibernate.proxy.HibernateProxy"
    cachedConstructor = null
    newInstanceCallerCache = null
    name = "org.hibernate.proxy.HibernateProxy"
    classLoader = {Launcher$AppClassLoader@9032} 
    reflectionData = {SoftReference@9067} 

Method threw 'javax.persistence.EntityNotFoundException' exception. Cannot evaluate com.basaki.example.book.data.entity.BookEntity_$$_jvst97c_0.toString()


Affects: 2.0 M3 (Kay)

@spring-projects-issues
Copy link
Author

Oliver Drotbohm commented

Actually, the exception is not expected as here's what the JavaDoc of EntityManager.getReference(…) says:

If the requested instance does not exist in the database, the <code>EntityNotFoundException</code> is thrown when the instance state is first accessed.

I.e., the method will always return an instance of the requested object and will expose the exception as soon as you access any of its methods

@spring-projects-issues
Copy link
Author

Jens Schauder commented

Without any further information we can't determine that anything is wrong on our side

@spring-projects-issues
Copy link
Author

Eduard Wirch commented

That's a duplicate of DATAJPA-1321

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core support status: declined A suggestion or change that we don't feel we should currently apply type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants