creating table in hibernate

creating table in hibernate

how to create table by the help of hibernate

View Answers

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 +++++++++++++


November 9, 2010 at 3:18 PM

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..


November 9, 2010 at 4:21 PM

< 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.









Related Tutorials/Questions & Answers:
creating table in hibernate
creating 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 jsp
creating 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
java coding for creating table in the console
java coding for creating table in the console  write a java program to create table
MYSQL - mysql copy table to another table example by creating new table
MYSQL - mysql copy table to another table example by creating new table  Hi, I have a table with many fields and hue data is in it. I want to create a new table with all the data from this table. How to create a new table
Hibernate Temporary Table
Hibernate Temporary Table   How can i create temporary table in Hibernate
how to creating hbm files in hibernate using Myeclipse
how to creating hbm files in hibernate using Myeclipse  how to creating hbm files in hibernate using Myeclipse
Hibernate envers revinfo table
Hibernate 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 Hibernate
How 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 instance
Hibernate 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
Creating Hibernate Sessions and Transactions through Spring - AOP .
Creating Hibernate Sessions and Transactions through Spring - AOP .  Hi, I am facing some technical issues in creating the Hibernate Sessions and Transactions using Spring-AOP. Can you provide a sample code where Hibernate
Creating Hibernate Sessions and Transactions through Spring - AOP .
Creating Hibernate Sessions and Transactions through Spring - AOP .  Hi, I am facing some technical issues in creating the Hibernate Sessions and Transactions using Spring-AOP. Can you provide a sample code where Hibernate
Creating Hibernate Sessions and Transactions through Spring - AOP .
Creating Hibernate Sessions and Transactions through Spring - AOP .  Hi, I am facing some technical issues in creating the Hibernate Sessions and Transactions using Spring-AOP. Can you provide a sample code where Hibernate
Creating Hibernate Sessions and Transactions through Spring - AOP .
Creating Hibernate Sessions and Transactions through Spring - AOP .  Hi, I am facing some technical issues in creating the Hibernate Sessions and Transactions using Spring-AOP. Can you provide a sample code where Hibernate
Creating Hibernate Sessions and Transactions through Spring - AOP .
Creating Hibernate Sessions and Transactions through Spring - AOP .  Hi, I am facing some technical issues in creating the Hibernate Sessions and Transactions using Spring-AOP. Can you provide a sample code where Hibernate
Joining Multiple table in Hibernate
Joining 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
delete row from a table in hibernate
delete row from a table in hibernate  is there method to delete row in a table using hibernate like save(-) to insert row
Hibernate table not mapped error - solution
Hibernate 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 hibernate
creating 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 table
Hibernate 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
can we update table in hibernate with out primary key in table?
can we update table in hibernate with out primary key in table?  can we update table in hibernate with out primary key in table
Retrieve Value from Table - Hibernate
Retrieve 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.. 
Session #1 - Hibernate introduction and creating CRUD application
Session #1 - Video tutorial of Hibernate introduction and creating CRUD application. Example code of insert, update, search and delete data using Hibernate... Framework: ADS_TO_REPLACE_7 Here is the SQL code for creating table for running
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 exist
Hibernate 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
How to import data from sql server table into an excel file by creating the rows dynamically in the excel according to the dataabase??
How to import data from sql server table into an excel file by creating... data from sql server table into an excel file by creating the rows dynamically in the excel according to the dataabase?? There is a table in sql server having
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 table
Hibernate 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
Hibernate 4 create Session Factory: Example of creating Session Factory in Hibernate 4
for creating the application. Hibernate 4 is undoubtedly very popular and robust framework for creating enterprise application. Hibernate 4.3.0 is the JPA... the code for creating the SessionFactory instance in your application. Hibernate
Delete database Table through hibernate and Spring
Delete 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 table
Hibernate 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 hibernate
delete 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. 
How properties of a class are mapped to the columns of a database table in Hibernate?
Hibernate Mapping:  How properties of a class are mapped to the columns of a database table in Hibernate? Hibernate 5 is very powerful yet flexible ORM... properties to database table Hibernate 5 is mostly using the annotations
How properties of a class are mapped to the columns of a database table in Hibernate?
Hibernate Mapping:  How properties of a class are mapped to the columns of a database table in Hibernate? Hibernate 5 is very powerful yet flexible ORM... properties to database table Hibernate 5 is mostly using the annotations
How properties of a class are mapped to the columns of a database table in Hibernate?
Hibernate Mapping:  How properties of a class are mapped to the columns of a database table in Hibernate? Hibernate 5 is very powerful yet flexible ORM... properties to database table Hibernate 5 is mostly using the annotations
How properties of a class are mapped to the columns of a database table in Hibernate?
Hibernate Mapping:  How properties of a class are mapped to the columns of a database table in Hibernate? Hibernate 5 is very powerful yet flexible ORM... to map Java properties to database table Hibernate 5 is mostly using
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
table
table  multiplicatyion table
TABLE
TABLE   Why doesn't <TABLE WIDTH="100%"> use the full browser width
Table
Table  How i generate table in showMessageDialog. I want that i creat a table and run in showMessageDialogeprint("cprint("code sample");ode sample
Table
Table  How I generate table in showMessageDialog. E.g 3X1=3 3X2=6 3X3=9print("code sample
Table
Table  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
table
table  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
Table
Table  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
Table
Table  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
Table
Table  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 Insert
This tutorial will help you to learn how to insert data into table by using hibernate

Ads