I'm facing problem while typecasting customer class to object class in hibernate :
public class HibernateCustomerDAO implements CustomerDAO {
@Override
public int addCustomer(CustomerDTO cto) {
Customer cust = new Customer(cto.getName(), cto.getEmail(), cto.getTelephone(), cto.getAge(), cto.getTime());
Integer it = (Integer)HibernateTemplate.save(cust);
return it.intValue();
}
}
problem comming to the code given bellow:
public static Object save(Object obj) {
Object o = null;
try {
SessionFactory sf = HibernateUtil.getSessionFactory();
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
o = session.save(obj);
tx.commit();
session.close();
} catch(Exception e) {
e.printStackTrace();
}
return o;
}
Session.save returns a Serializable- Object. (http://docs.jboss.org/hibernate/orm/3.5/javadocs/org/hibernate/Session.html#save%28java.lang.Object%29)
But Object doesn't implement the marker interface Serializable. (http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With