I have a DAO class which I'm using to try select/update/insert with hibernate and Mysql database. I'm writing methods for these now, I already wrote insert like this :
public Long save(People transientInstance) {
log.debug("Saving People instance");
try {
Long id = (Long)getHibernateTemplate().save(transientInstance);
log.debug("save successful with id #" + id);
return id;
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
I have a 3 columns, one is id
, second is name
, third is surname
. Using the same logic how can I get person by ID or update person. Now I can wrote delete also :
public void delete(People persistentInstance) {
log.debug("deleting People instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
I could delete or update if I could get the People object by ID but I don't know how. Thank you( yes I'm trying to learn java-spring-hibernate go easy on me pls)