if you want to get something first you need to put something. This rule works everywhere. In your code you need to put the model object to DAO. Then DAO will save it to the db using the values populated in the model via the interceptor. For example
Empmodel queryresult = empdao.add(model);
For this to work you need to change the method signature to add a parameter for model
.
The thing seems trivial but you need to remove the statement that recreate the model
in the method implementation, it is not working fine. Also make sure that the model is not empty before you start transaction.
The save
method in DAO should check if the new object is created that has null
value for id
.
if (model.getId() == null)
session.save(model);
else
session.update(model);
}
How to implement a ModelDriven
with integration hibernate example