• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

remarkable error: status 500; No serializer found for class com.crud.demo.dto.EmployeeDto and no pro

 
Ranch Hand
Posts: 34
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I try to learn JPA/Hibernate and last week I had a remarkable error:

"status": 500,
"error": "Internal Server Error",
"trace": "org.springframework.http.converter.HttpMessageConversionException:
Type definition error: [simple type, class com.crud.demo.dto.EmployeeDto];
nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException:
No serializer found for class com.crud.demo.dto.EmployeeDto and no properties discovered
to create BeanSerializer



In my DTO I had only setters implemented, because if need getters than I thought I will do this from the Entity ==> the unique source.

After some hours I added in my DTO classes the getters and the getter for the id was immediately syntax highlighted --> collaring which means it is used. So Im searching where? And IntelliJ 'Find usage' I get the message "Usages or base methods of getId() Nothing found in 'All Places'"


Is that not strange? At least it is now working but I don't understand it...

 
Saloon Keeper
Posts: 24321
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In JPA you don't need DTOs, because the Entity objects themselves can operate as DTOs.

From your error message, I'm thinking that this wasn't actually a JPA problem but a problem with XML serialization.

You can, incidentally, use the same class definition for both a JPA Entity and an XML node, if you use the right annotations. You don't need any intermediate classes.
 
Marshal
Posts: 22453
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:From your error message, I'm thinking that this wasn't actually a JPA problem but a problem with XML serialization.


Don't be fooled by the fasterxml part. Jackson is more famous for JSON serializing and deserializing.

By default, Jackson uses getters for object -> JSON and setters for JSON -> object. You can use several annotations to tweak this behaviour. One of them is @JsonAutoDetect which you can annotate a class with to tell Jackson to use fields, not methods.
 
reply
    Bookmark Topic Watch Topic
  • New Topic