I am new to hibernate and having a lot of confusions.
I created 3 classes.
I have User and Category properties in Expense.java
Now when i am trying to persist only the expense object after setting the User and Category properties, i am getting TransientObjectException because i am not persisting the User and Category objects to the database.
But when I persist them before persisting the Expense object using session.save(), it works fine.
I have <many-to-one> association in Expense.hbm.xml for both User and Category, because multiple expenses can have single or many users with single or many categories.
So what is the case when we have to explicitly save these objects first and then the final object, and when is not the case.
What is the actual concept behind this? I want the User and the Category objects to automatically get persisted when i call session.save(expenseobject);