You'll need an annotation or something on yearDepartentId.
You can always use a compound key class. Here's an example where I have a copound key of userId and bankId
Then in your code, you declare the @Id of this type:
How To Use Compound Primary Keys In Your Code
Other options include using the @IdClass annotation or @EmbeddedId. This
tutorial covers each of them. But that other field needs to be treated somehow.