I am new with Spring + Hibernate +icefaces with MyEclipse 7. I might have a problem with a DAO: no error message but I cannot see any data record in IceFaces page;
would you help me
I am using:
- MyEclipse Derby as database
- myEclipse 7 Bench
- Spring 2.5
- Hibernate 3.2
//CustomerDAO
Code:
package com;
skip for import libraries
public class CustomerDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(CustomerDAO.class);
// property constants
public static final String CUSTOMERNAME = "customername";
public static final String CONTACTLASTNAME = "contactlastname";
public static final String CONTACTFIRSTNAME = "contactfirstname";
public static final String PHONE = "phone";
public static final String ADDRESSLINE1 = "addressline1";
public static final String ADDRESSLINE2 = "addressline2";
public static final String CITY = "city";
public static final String STATE = "state";
public static final String POSTALCODE = "postalcode";
public static final String COUNTRY = "country";
public static final String SALESREPEMPLOYEENUMBER = "salesrepemployeenumber";
public static final String CREDITLIMIT = "creditlimit";
protected void initDao() {
// do nothing
}
private EntityManager getEntityManager() {
return EntityManagerHelper.getEntityManager();
}
public void save(Customer transientInstance) {
log.debug("saving Customer instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Customer persistentInstance) {
log.debug("deleting Customer instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Customer update(Customer detachedInstance) {
EntityManagerHelper.log("updating Customer instance", Level.INFO, null);
try {
Customer result = getEntityManager().merge(detachedInstance);
EntityManagerHelper.log("update successful", Level.INFO, null);
return result;
} catch (RuntimeException re) {
EntityManagerHelper.log("update failed", Level.SEVERE, re);
throw re;
}
}
public Customer findById(java.lang.Integer id) {
log.debug("getting Customer instance with id: " + id);
try {
Customer instance = (Customer) getHibernateTemplate().get(
"com.Customer", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Customer instance) {
log.debug("finding Customer instance by example");
try {
List results = getHibernateTemplate().findByExample(instance);
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
public List findByProperty(String propertyName, Object value) {
log.debug("finding Customer instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Customer as model where model."
+ propertyName + "= ?";
return getHibernateTemplate().find(queryString, value);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByCustomername(Object customername) {
return findByProperty(CUSTOMERNAME, customername);
}
public List findByContactlastname(Object contactlastname) {
return findByProperty(CONTACTLASTNAME, contactlastname);
}
public List findByContactfirstname(Object contactfirstname) {
return findByProperty(CONTACTFIRSTNAME, contactfirstname);
}
public List findByPhone(Object phone) {
return findByProperty(PHONE, phone);
}
public List findByAddressline1(Object addressline1) {
return findByProperty(ADDRESSLINE1, addressline1);
}
public List findByAddressline2(Object addressline2) {
return findByProperty(ADDRESSLINE2, addressline2);
}
public List findByCity(Object city) {
return findByProperty(CITY, city);
}
public List findByState(Object state) {
return findByProperty(STATE, state);
}
public List findByPostalcode(Object postalcode) {
return findByProperty(POSTALCODE, postalcode);
}
public List findByCountry(Object country) {
return findByProperty(COUNTRY, country);
}
public List findBySalesrepemployeenumber(Object salesrepemployeenumber) {
return findByProperty(SALESREPEMPLOYEENUMBER, salesrepemployeenumber);
}
public List findByCreditlimit(Object creditlimit) {
return findByProperty(CREDITLIMIT, creditlimit);
}
public List findAll() {
log.debug("finding all Customer instances");
try {
String queryString = "from Customer";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Customer merge(Customer detachedInstance) {
log.debug("merging Customer instance");
try {
Customer result = (Customer) getHibernateTemplate().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Customer instance) {
log.debug("attaching dirty Customer instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Customer instance) {
log.debug("attaching clean Customer instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static CustomerDAO getFromApplicationContext(ApplicationContext ctx) {
return (CustomerDAO) ctx.getBean("CustomerDAO");
}
}