November 9, 2010 at 3:07 PM
There are 2 alternatives to create table in hibernate:
1.) .hbm.xml
2.) Annotation.
Example 1: via .hbm.xml
==========================================
/* 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 */
This class contains course details.
Example 2: via Annotation
==========================================
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
+++++++++++++
Related Tutorials/Questions & Answers:
creating table in hibernatecreating table in hibernate how to create
table by the help of
hibernate
There are 2 alternatives to create
table in
hibernate:
1...
table in my oracle database by the help of
hibernate, so if you would help me
creating instance of table in jspcreating instance of
table in jsp i face senario look kie as follows... file is obviously a jsp page and shows the output in
table manner.
3) now i want to make the instance of the data present in that paarticular
table....
how i do
Advertisements
Hibernate envers revinfo tableHibernate envers revinfo table Hi,
What is the structure of
hibernate envers revinfo
table?
What is the use of envers revinfo
table and its structure?
Thanks
How to update table in HibernateHow to update
table in Hibernate Hi, I have a
table in database that has two fields in it. Student Name and ID, can anyone explain me how to update these tables in
Hibernate.
Thanks.
Update
table query in
Hibernate Hibernate Creating criteria instanceHibernate Creating criteria instance
In this section you will learn about the
creating of criteria instance in
Hibernate.
An instance of Criteria is created... at first a
table from where you will required to
retrieve a stored data
Joining Multiple table in HibernateJoining Multiple
table in Hibernate Hi everyone,
I'm new to
Hibernate (even in JAVA), and I'm having some doubt's about one thing. I created 2... (using System.out.println) the query results. I've been using (just for one
table Hibernate table not mapped error - solutionHibernate table not mapped error - solution Hi,
What is the reason of
Hibernate table not mapped error and it can be solved?
Thanks
HI... configuration of Entity class in
Hibernate.
Hibernate is ORM framework in Java which
creating and executing stored procedure using hibernatecreating and executing stored procedure using hibernate I have to execute following query using
hibernate
DECLARE @i_STARTDATETIME DATETIME
DECLARE @i_ENDDATETIME DATETIME
DECLARE @o_ERRORCODE INT
DECLARE @o_ERRORDESCRIPTION
Hibernate Envers custom revinfo tableHibernate Envers custom revinfo table Hi,
How to use the custom
table instead of revinfo
table?
I don't want to use the default
table I want to give another name for this
table. How to do this?
Thanks
Retrieve Value from Table - HibernateRetrieve Value from
Table Hai friend,
I need help, How can i retrieve values From database using
hibernate in web Application. As I new to
hibernate I couldn't find solution for this problem.. Can anyone help please..
Creating a Hash Table Creating a Hash
Table : Java Util
...
table. What is the hash
table
and how to create that? Hash
Table holds... for several values. Hash
Table is
created using an algorithm (hashing function
Creating Table in Echo3
Creating Table in Echo3
... in the nextapp.echo.app
package. There are four constructors provided for
creating a
table in Echo3....
In this example of
creating Table in Echo3 we have
created a simple application
Hibernate Envers - REVINFO table doesn't existHibernate Envers - REVINFO
table doesn't exist Hi,
In my project I...:
Hibernate Envers - REVINFO
table doesn't exist
How to resolve this?
Thanks...
hibernate to create
table automatically. For this add following property
Creating table using DBCP = con.createStatement();
String QueryString = "CREATE
TABLE user_master1(User_Id INTEGER...(QueryString);
System.out.println("
Table created!!");
con.close();
} catch
Hibernate envers custom revinfo tableHibernate envers custom revinfo
table - How to specify custom revinfo
table?
In this tutorial we are going to teach you to configure the
Hibernate... in the
tutorial.
In
Hibernate envers its possible to use the custom revinfo
table Delete database Table through hibernate and SpringDelete database
Table through
hibernate and Spring Hi,
I am using Spring,
Hibernate and Tapestry to save and also fetch data simultaneously from... once without repetation,or Detete
table after data is fetched.
Here
Hibernate Criteria load all objects from tableHibernate Criteria load all objects from
table - Learn how to load all...
from a
table then you can easily use the
Hibernate Criteria load all objects... Criteria Query to
fetch all data from a
table. Read more
Hibernate Criteria
delete row from a table using hibernatedelete row from a
table using hibernate //code in java file
String hql="delete from CONTACT c where ID=6";
Query query=session.createQuery(hql);
//error when executing above code
CONTACT is not mapped
MySQL Create Table
MySQL Create
Table
Here, you will read the brief description about the MySQL create
table. The
CREATE
TABLE statement is used for
creating a
table in database.
Creating a MySQL Database Table to store Java Types
Creating a MySQL Database
Table to store Java Types... are providing you an example with code for
creating a
table to store java types. Brief... to store a
java types in our database
table. Now one question may arise in your
tabletable multiplicatyion
table TABLE TABLE Why doesn't <
TABLE WIDTH="100%"> use the full browser width
TableTable How i generate
table in showMessageDialog. I want that i creat a
table and run in showMessageDialogeprint("cprint("code sample");ode sample
TableTable How I generate
table in showMessageDialog.
E.g
3X1=3
3X2=6
3X3=9print("code sample
TableTable How i generate
table in showMessageDialog. I want to creat a
table and run in showMessageDialoge. Pl make a
table programe which run..., JOptionpane, Integer.parseInt.
Please use only these above methods to make
table table input from oracle
table(my database
table..)
This is a very important
table of my
tabletable Hi..I have a list of links which links to a
table in the same page.If I click first link the
table is displayed at the top, likewise if i click the last link the
table is displayed at the last,i dont know how to set
TableTable How i generate
table in JOptionpane.showMessageDialog... advance coding
but i want u make the
table using JOptionpane.showMessageDialog, import.javax.swing
int Integer.parseInt().
Thats my limit. Pl generata a
table table?table? Hi, how could i make a
table in javascript, which would look like this:
AA CODON Number /1000 Fraction .. (this row... can't figure out, how to construct a
table,with two fixed columns, one that reads
TableTable Why u dont understand sir?? I want to make a
table program which generate a
table on showMessageDialog. I have learnt these methods until now... methods to be used.
Write a
table program which use only and only these above methods
TableTable How i create
table on showMessageDialog using JOptionpane and Integer.parseInt.
No other method to use. Pl make a program which generate
5X1=5
5X2=10
5X3=15
Hi Friend,
Try this:
import javax.swing.*;
import
Hibernate InsertThis tutorial will help you to learn how to insert data into
table by using
hibernate