Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
19,822 Points

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