I have a products objects which belongs to certain categories i.e. classical many to one relationship.
@Entity public class Product{ @Id @GeneratedValue
I've just tried following:
Category category = new Category(categoryId); product.setCategory(category);
And it worked, i mean product record in db got correct link to category and category with id
categoryId
haven't changed.