Im using Hibernate with Annotations.
This is my entity class;
===============
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name="ORDER_OF_SALE")
public class OrderOfSale implements Serializable {
getters and setters goes here.
}
This is my hibernate utilization;
====================
public String hibInsert(Object tblObj) throws Exception{
Session session = null;
AnnotationConfiguration ac = new AnnotationConfiguration();
session = ac.configure().buildSessionFactory().openSession();
if (tblObj != null) {
try {
Transaction beginTransaction = session.beginTransaction();
session.save(tblObj);
beginTransaction.commit();
if (beginTransaction.wasCommitted()) {
return "1210";
//response.sendRedirect("index.jsp");
} else {
return "Operation failed";
}
} catch (HibernateException hbe) {
return "Operation failed " + hbe.toString();
} finally {
session.flush();
session.close();
}
} else {
return "Required fields are not filled";
}
}
;;;;;;;;;;;;;;;;;;;;;
In above function tblObj is saved as POJO. The attribute values want to set to above 'OrderOfSale' class.
Everything is ok, but executing 'session.save(tblObj);' it gives this error message.
'Operation failed org.hibernate.MappingException: Unknown entity: com.aura.data.trn.OrderOfSale'
I think my Entity class has defined well, but i cannot solve this problem.
Please help me.
Thanks,
Dilan Alex
|