
how to create table by the help of hibernate

There are 2 alternatives to create table in hibernate:
1.)
2.) Annotation.
==========================================
/* Class Course */
package com.mypkg.course;
import java.io.Serializable;
public class Course implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private long courseID;
private String courseName;
public Course() {
super();
}
public Course(String courseName) {
super();
this.courseName = courseName;
}
public long getCourseID() {
return courseID;
}
public void setCourseID(long courseID) {
this.courseID = courseID;
}
public String getCourseName() {
return courseName;
}
public void setCourseName(String courseName) {
this.courseName = courseName;
}
}
/* Course.hbm.xml */
==========================================
package mypkg.course;
import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table;
@Entity @Table(name = "TBLCOURSES") public class Course {
private int courseID;
private String courseName;
@Id
@GeneratedValue
@Column(name = "COURSEID")
public int getCourseID() {
return courseID;
}
public void setCourseID(int courseID) {
this.courseID = courseID;
}
@Column(name = "COURSENAME")
public String getCourseName() {
return courseName;
}
public void setCourseName(String courseName) {
this.courseName = courseName;
}
public Course(String courseName) {
super();
this.courseName = courseName;
}
public Course() {
super();
}
}
I think that this much is efficient for your problem. For any further issues feel free to ask.
+++++++++++++ knapster +++++++++++++

thanks a ton,
But i want to create a new table in my oracle database by the help of hibernate, so if you would help me regarding this please tell me about that with example, it is very urgent to me and i didn't get any other source to ask this question..

< property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver
< property name="hibernate.connection.url">jdbc racle:thin:@127.0.0.1:1521 XYZ
< property name="hibernate.connection.username">sys
< property name="hibernate.connection.password">dba
< property name="hibernate.connection.pool_size">10
< property name="show_sql">true
< property name="dialect">org.hibernate.dialect.OracleDialect
create configuration file for oracle database. I think it will solve ur prob.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.