I am trying update marks through a dialog box.but it is showing error.
This is my POJO class called Student, I have created one table for that to update marks.
@Entity
public class Student
{
@Id
private int sid;
@Column(length=10)
private String sname;
private int marks;
@Version
private int verson;
public int getSid() {
return sid;
}
public void setSid(int sid) {
this.sid = sid;
}
public String getsname() {
return sname;
}
public void setsname(String sName) {
this.sname = sName;
}
public int getMarks() {
return marks;
}
public void setMarks(int marks) {
this.marks = marks;
}
public int getVerson() {
return verson;
}
public void setVerson(int verson) {
this.verson = verson;
}
}
This is my main class
public class ClientOfUser1 {
public static void main(String[] args)
{
Configuration conf=new Configuration().configure("hibernate.cfg.xml");
ServiceRegistry registry=new StandardServiceRegistryBuilder().applySettings(conf.getProperties()).build();
SessionFactory factory=conf.buildSessionFactory(registry);
Session session=factory.openSession();
Transaction tx=session.beginTransaction();
Student s=(Student)session.get(Student.class, 101);
String str=JOptionPane.showInputDialog("enter marks of (User1)");
int m= Integer.parseInt(str);
s.setMarks(m);
tx.commit();
session.close();
factory.close();
}
}
When I'm trying to execute this, it is showing another error also the error is "STUDENT0_"."VERSON": invalid identifier
Try to put
in application.properties
Otherwise explicitly specify studaent table name and schema name with @Table annotation