The
Category you use is a fresh new object. It has no id set, so Spring Data / JPA treats it as a new entity. It will therefore try to insert it. Whether or not that succeeds depends on your unique constraints.
What you need to do is use a
CategoryRepository to find the
Category by its name, then use the result in the
Activity.
Note that we've had something similar recently in
https://coderanch.com/t/745425/databases/ERROR-OneTOMany-ManyToOne-mapping-FK. There's one big difference though - there the linked record (in this case
Category) was identified by its id, not a different field. I also don't see any methods on
CrudRepository that lets you get a reference based on the id, only a full entity.