Reading the Hibernate documentation on
associations really would help.
OK, lets look at what you have here:
This is a mapping for a class called employee, which has the following properties and types:
employeeId (int)name (String)job (String)departmentId (int)departmentId (department) The last two look suspect - Hibernate is complaining because you have two properties mapped to the same field one should be read only.
If you think about it, based on what you have, I'd expect a class that looked like this:
You will see that this class in not valid
Java.
What you've defined here:
is known as a unidirectional many-to-one association. If you look in the
documentation for an example you'll find a good right at the top of the section on mapping associations.