Hibernate is complaining because it must have a category ID to save into the category_id column of the pet table, but you have no ID to save.
To work around this without using CategoryDAO, have a precondition for you tests be that there must be a row in the category table with ID = 1, and that any category object you create for unit testing purposes must have ID 1. Hibernate will match your transient category object with the dummy unit test category row, and all will be well.
_________________ Code tags are your friend. Know them and use them.
|