Friday, 22 July 2011

How Create table by Hibernate

Step -1 Create hibernate.cfg.xml
Step-2 Create Class Student.java
import javax.persistence.id;
import javax.persistence.entity;
@Entity
class Student implements java.io.serializable {
 private String  id;
private String name:
  @Id
 public String getId(){
 return id;
}
 public String setId(String id)
{
 this.id=id;
}
 public String getName(){
 return Name;

}

 public String setName(String Name)

{
 this.Name=Name;

}

Step 3 create Main.java
  
import org.hibernate.*; 

class Main{

public static void main(String[] arg){

AnnotatedConfiguration cf=new AnnotatedConfiguration();
 cf.configure();
cf.addAnnotatedClass(Student.Class);
new SchemaExport(cf).create(true,true);
 }


 } 







No comments:

Post a Comment