Reagrsding Hibernate joins

Reagrsding Hibernate joins

Hi, I am trying to make join in Hibernate.

View Answers

April 12, 2008 at 7:12 PM

Hi friend,

package roseindia;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateExample {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

Session session = null;

try{
// This step will read hibernate.cfg.xml and prepare hibernate for use
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
org.hibernate.Transaction tr = session.beginTransaction();
//Create new instance of Contact and set values in it by reading them from form object
System.out.println("Inserting Record");
Contact contact = new Contact();
CONTACT1 con = new CONTACT1();
con.setId(3);
contact.setId(5);
contact.setFirstName("Vinod");
contact.setLastName("Kumar");
contact.setEmail("[email protected]");
con.setAddress("rohini,sec-3,delhi-85");
con.setState("bihar");
session.save(con);
session.save(contact);
tr.commit();
System.out.println("Done");
}catch(Exception e){
System.out.println(e.getMessage());
}
finally{
// Actual contact insertion will happen at this step
//session.flush();
session.close();

}


}

}

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">;

<hibernate-mapping>
<class name="roseindia.Contact" table="CONTACT">
<id name="id" type="int" column="ID" >
<generator class="assigned"/>
</id>

<property name="firstName">
<column name="FIRSTNAME" />
</property>
<property name="lastName">
<column name="LASTNAME"/>
</property>
<property name="email">
<column name="EMAIL"/>
</property>
</class>

<class name="roseindia.CONTACT1" table="CONTACT1">
<id name="id" type="int" column="ID" >
<generator class="assigned"/>
</id>

<property name="address">
<column name="Address" />
</property>
<property name="state">
<column name="State"/>
</property>

</class>

</hibernate-mapping>


--------------------------

Hope it will help u.

read for more information,

http://www.roseindia.net/hibernate/









Related Tutorials/Questions & Answers:
Reagrsding Hibernate joins - Hibernate
Reagrsding Hibernate joins  Hi, I am trying to make join in Hibernate...{ // This step will read hibernate.cfg.xml and prepare hibernate for use..."?><!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate
hibernate joins
hibernate joins  how to fetch the data from multiple tables in mysql using HQL. Give me one example using joins
Advertisements
Hibernate Joins
In this section, you will learn about types of joins in Hibernate
Hibernate Associations and Joins Examples
Hibernate Associations and Joins Examples  How to write examples of Associations and Joins in Hibernate? Thanks   Hi, Please check... and Joins in Hibernate. You will learn how to create Associations and Joins
Associations and Joins Example in Hibernate
Associations and Joins Example in Hibernate  I am new to Hibernate programming and looking for good example of Associations and Joins in Java. Tell... and Joins. Check the Latest tutorials, articles and examples of Hibernate
How to use Associations and Joins in Hibernate?
How to use Associations and Joins in Hibernate?  Hi. I am trying to find the examples of Associations and Joins in Hibernate. Give me the code and examples of Associations and Joins in Hibernate. Thanks   Hi, Please
JOINS
JOINS  hii,, What is joins?   hii,ADS_TO_REPLACE_1 join provides relationship between two or more table. If we want to access data from more then one table at a time we use join
Hibernate Outer Join
In this section, you will learn about types of outer joins in Hibernate
Hibernate Aggregate Functions(Associations and Joins)
Hibernate Aggregate Functions(Associations and Joins... understand about the aggregate function of Hibernate with the help of example.  In Hibernate HQL queries are capable of returning the results of the aggregate
How are joins handled using Hinernate?
How are joins handled using Hinernate?  Hi, How are joins handled using Hinernate? Thanks
SQL JOINS - SQL
SQL JOINS  Hom many Joins In Sql?plz explian all those things?  Hi Friend, Please visit the following link: http://www.roseindia.net/sql/sqljoin/index.shtml Hope that it will be helpful for you. Thanks
ModuleNotFoundError: No module named 'faust-joins'
ModuleNotFoundError: No module named 'faust-joins'  Hi, My Python... 'faust-joins' How to remove the ModuleNotFoundError: No module named 'faust-joins' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'faust-joins'
ModuleNotFoundError: No module named 'faust-joins'  Hi, My Python... 'faust-joins' How to remove the ModuleNotFoundError: No module named 'faust-joins' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'faust-joins'
ModuleNotFoundError: No module named 'faust-joins'  Hi, My Python... 'faust-joins' How to remove the ModuleNotFoundError: No module named 'faust-joins' error? Thanks   Hi, In your python environment
Associations and Joins
Associations and Joins      ... and Joins along with examples. Association mappings: Association mappings comes... these keys do not require good practice in traditional data modeling. Hibernate
What is a join and explain different types of joins
and explain different types of joins?   Hi, Joins are used in queries to explain how different tables are related. Joins also let you select data from a table depending upon data from another table.ADS_TO_REPLACE_1 Types of joins
SQL INNER Joins
SQL INNER Joins      ... from SQL INNER Joins. The Example helps you to know the use of SQL INNER Joins. The create table statement is used to create a tables 'Stu_Table
how to update table using inner joins
how to update table using inner joins  how to update table using inner joins
Joins
Joins       Sometimes... that linking the rows from multiple tables together. Types of Joins :ADS_TO_REPLACE_1 INNER Joins OUTER Joins SELF Joins We are going to describe you the Join
HIBERNATE
HIBERNATE   What is difference between Jdbc and Hibernate
hibernate
hibernate  what is hibernate flow
hibernate
hibernate  what is hibernate listeners
hibernate
hibernate  how to uses optional column in hibernate
hibernate
hibernate  please give me the link where i can freely download hibernate software(with dependencies)   Learn hibernate, if you want to learn hibernate, please visit the following link: Hibernate Tutorials
Hibernate
Hibernate  hibernate delete query execution
hibernate
hibernate  what is hibernate why we use
Hibernate
Hibernate  how to use pagination concept in Hibernate
hibernate
hibernate   I want to learn how to use hibernate framework in web application . for storing database in our application
hibernate
hibernate   I want to learn how to use hibernate framework in web application . for storing database in our application
hibernate
why hibernate?  why hibernate?   Hibernate: -Hibernate... library. It solves object-relational impedance mismatch problems. Hibernate makes the application development process easy Hibernate saves the development
hibernate
hibernate  pls give one simple example program for hibernate
hibernate
hibernate  why we should use hibernate projection
Hibernate
Hibernate  Please tell me the difference between hibernate and jdbc
Hibernate
Hibernate  hello, how to run hibernate program in netbeans?please send me step by step instructions to run hibernate in netbeans
hibernate
hibernate  can any one one explain what is hibernate ?   Please visit the following link: Hibernate Tutorials
hibernate
hibernate  how to execute a sequence(in database) from Hibernate program or java program   Please visit the following link: Hibernate Tutorials
Hibernate
Hibernate  How do you handle parent - child tables relationships in hibernate? How do you handle Detach state in hibernate
Hibernate - Hibernate
Hibernate Features  Hibernate features in eclipse
hibernate
hibernate  how to impot mysql database client jar file into eclipse for hibernate configuration   Hi Friend, Please visit the following link:ADS_TO_REPLACE_1 http://www.roseindia.net/hibernate/runninge-xample.shtml
Hibernate
Hibernate  hi sir i need hibernate complete tutorial for download   Hi Friend, Please visit the following link: Hibernate Tutorials Thanks
hibernate
hibernate  How to know how many columns changed in a table when we are using hibernate
hibernate
hibernate  hi what are the necessary jar files that we need to set in the classpath to execute a hibernate application
HIBERNATE
HIBERNATE  How u connects database using hibernate 3.0? Where you have written the database configuration details
hibernate
hibernate   i am using hibernate3.2.5 and oracle9i. First i set classpath to ojdbc14.jar and all the hibernate jar files to path env variable.After that when i try to execute the program i got an error "unknown oracle major
hibernate
hibernate  Is there any other way to call procedure in hibernate other than named query????? if we are using session object to get the connection then why hibernate we can directly call by using a simple java class??????? please
hibernate
hibernate  when we using schemaExport in hibernate every time it drops the existing table and create new table ,if table contain dependent table then is it drop
hibernate - Hibernate
hibernate program shareware  hibernate program shareware example
Hibernate - Hibernate
Hibernate sessionfactory configuration  What is the process of hibernate sessionfactory configuration
Hibernate
of Hibernate. I followed all th steps as given in the tutorial, but a build error... hibernate library files are not included in the project build path.ADS_TO_REPLACE_1 Please download the example from Hibernate Getting Started Tutorial. Please
Hibernate
Hibernate  Hi i have 2 doubbts regarding Hibernate ,.. 1)Can we rename hibernate.cfg.xml? 2? can we use multiple mapping resource in hibernate.cf.xml file ? pls let me know soon

Ads