Reputation: 21
I want to insert the date in a customer table in Oracle database.
I have tow attributes id NUMBER(8)
and dtRt Date
//entity
@ Column (name = "DT_RT")
@ Temporal (TemporalType.TIMESTAMP)
private Date dtRt;
when converting
SimpleDateFormat formatter = new SimpleDateFormat ("dd / MM / yyyy");
date = formatter.parse (jFormattedTextField1.getText ());
I get:
Fri Mar 30 00:00:00 CET 14
but when I inserted into the table, the date is not inserted.
//DAO
public void add(Employe e)
{
EntityTransaction et = em.getTransaction();
et.begin();
em.persist(e);
et.commit();
}
// method on application client
public void add(int mat,String grade,String fonction, int cnprs,int cin,String np ,String adress,String tel,int disp,Date date)
{
Employe emp=new Employe();
Grade gr= bean.grade_emp(grade);
Fonction f= bean.fonction_emp(fonction);
emp.setMatEmp(mat);
emp.setNumGrd(gr.getNumGrd());
emp.setNumFon(f.getNumFon());
emp.setCnprs(cnprs);
emp.setCin(cin);
emp.setAdress(adress);
emp.setTel(tel);
emp.setNp(np);
emp.setDispo(disp);
bean.add(emp);
}
Upvotes: 0
Views: 126
Reputation: 691903
Well, the problem is simple: you never set the date of the employee in the add()
method. The date
argument of the method is ignored.
Upvotes: 1