Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Jeremiah Shore
Jeremiah Shore
31,168 Points

"No accessor to set property @javax.persistence.Id()" when versioning

edit: not sure what happened, but this got unlinked from the original video.

I ran into an issue where I would only get a 500 error response (below).

I couldn't find much information about this after 10 - 20 mins of searching. I did end up, however, finding a solution: I removed the final keyword from the id member declaration in BaseEntity.

I'm assuming this is okay, as it still has private access, and it shouldn't be able to persist a different value because of the @GeneratedValue annotation. Testing with a PUT request returned an updated course object as expected, and the ETag header was updated.

If anyone has any additional insight, I'm interested in learning more about why the id can't be final... maybe it's the version of spring that I'm using (up to date as of this post).

{
    "timestamp": "2019-02-27T03:54:16.376+0000",
    "status": 500,
    "error": "Internal Server Error",
    "message": "No accessor to set property @javax.persistence.Id() @javax.persistence.GeneratedValue(strategy=AUTO, generator=)private final java.lang.Long net.jeremiahshore.core.BaseEntity.id!",
    "path": "/courses/1"
}
Erick Luna
Erick Luna
20,282 Points

This solution helped me to solve the same issue, thanks!