Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Hibernate-Interview-Questions Map java Object to database.
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


samar
Map java Object to database.
1 Answer(s)      3 years and 9 months ago
Posted in : Hibernate Interview Questions


How do you map Java Objects with Database tables?


Advertisement
View Answers

March 8, 2011 at 7:14 PM


Hi Friends, There are to way for mapping of our java object to database..

Using annotation..

package net.roseindia.Model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "userinfo")
public class AddInformation implements Serializable {
    private String firstname;
    private int id;

    @Id
    @GeneratedValue
    @Column(name = "id")
    public int getId() {
        return id;
    }

    @Column(name = "firstname")
    public String getFirstname() {
        return firstname;
    }


    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public void setId(int id) {
        this.id = id;
    }   

}

By using hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="true" default-lazy="true">
    <class name="net.roseindia.model.EmployeeInfoModel" table="employeeinfo">
        <id name="id" column="id" type="java.lang.Integer">
            <generator class="increment" />
        </id>
        <property name="name" column="name" type="java.lang.String" />
        <property name="address" column="address" type="java.lang.String" />
    </class>
</hibernate-mapping>


Related Tutorials/Questions & Answers:
Map java Object to database.
Map java Object to database.  How do you map Java Objects with Database tables
Map Java Objects with Database tables
Map Java Objects with Database tables  How to map Java Objects with Database tables?   First write Java domain objects ie. beans with setter and getter methods. Then map java class to table and database columns to Java
Advertisements
How do you map Java Objects with Database tables?
How do you map Java Objects with Database tables?  Hi, How do you map Java Objects with Database tables? thanks
parse map in java
parse map in java  What is a Parser? Can you give the source code to parse map in Java
Java Map Example
Java Map Example  How we can use Map in java collection?   The Map interface maps unique keys to value means it associate value to unique...(String[] args) { Map mp = new HashMap(); mp.put(new Integer(2
Java Map
Java Map         In Java, a Map is a kind of generalized array. It provides a more general way of storing elements. It is an object that maps keys to values. Map
java code for PartialSearch using Map????
java code for PartialSearch using Map????  java code for Partial Search using Map
Map
Map  If I have an object implementing the Map interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map either iterator or for each loop or for loop
Java tree map trouble
Java tree map trouble  This is a project for a class, and I am totally stuck! I've created a tree map using an input text file. I split the lines into fields so that I could work with 2 elements from the file. It appears
Java map building - Development process
Java map building  Hello All I want to build a map for a road... to proceed further i need to build a map using these coodinates which i am unable to think of how to do it. I can only use java swing or 2d for this purpose. Any
Java Map iterator with example
() method to get the data in Set object form. Java Map Iterator with Example... Java Map Iterator is an interface. It keeps the data in the key and value form. It is implemented by HashMap, Tree Map. Map has no iterator method. So
Java Map Example
and value. Each key-value pair is saved in a java.util.Map.Entry object. Map... the key and values. Map.Entry defines both of these methods. Java Map Example...Map Interface adds keys to values. Every key in the Map Interface should
map
map  using map, i want display message based on id selected [both are strings]   i do no   Hi Friend, Try the following code...) { Map map=new HashMap(); map.put("Message1","Hello
java code to compare two hash map objects
java code to compare two hash map objects  java code to compare two hash map objects
Java object
Java object  Which class should you use to obtain design information about an object
adding multiples markers to google map from a mysql database
adding multiples markers to google map from a mysql database   hello, i am trying to add markers to my googlemaps map. the latitudes and longitudes are strored in table called appreciation in a mysql database. i followed sevrel
adding multiples markers to google map from a mysql database
adding multiples markers to google map from a mysql database   hello, i am trying to add markers to my googlemaps map. the latitudes and longitudes are strored in table called appreciation in a mysql database. i followed sevrel
adding multiples markers to google map from a mysql database
adding multiples markers to google map from a mysql database   hello, i am trying to add markers to my googlemaps map. the latitudes and longitudes are strored in table called appreciation in a mysql database. i followed sevrel
adding multiples markers to google map from a mysql database
adding multiples markers to google map from a mysql database   hello, i am trying to add markers to my googlemaps map. the latitudes and longitudes are strored in table called appreciation in a mysql database. i followed sevrel
Java object
Java object  What is mutable object and immutable object?  An Immutable object is a kind of object whose state cannot be modified after it is created. This is as opposed to a mutable object, which can be modified
google map with jsf - Java Server Faces Questions
google map with jsf  hi, i am using jsf with googlemap.i load the script file with googlemap .its working fine.how can i load the database... from database values.could u help me. thanks, Regards, krishnaraj
Using Arraylist or Hash Map - Java Interview Questions
Using Arraylist or Hash Map  what could b the pros and cons changing between Hash Map to Array List
Java Map Iterate
Map is an Interface in the Collection Framework. Map is implemented by its two sub classes HashMap Treemap Map has no iterator method. So use the entrySet() method.It returns the data as Set Example of Java Map
Introduction to Map and SortedMap Interface
in a java.util.Map.Entry object. A set of these map entries can be obtained by calling a map's... C:\nisha>java MapDemo Keys of tree map: [0, 1, 2, 3, 4... Introduction to Map and SortedMap Interface
Object in java - Java Beginners
Object in java  Hi deepak, I am new to java, can u tell me what is class ,object and instance with example. For example : class raja , raja r.../java/master-java/java-object-oriented-language.shtml http
Java object clone
Java object clone  What is criteria for a object to get cloned
how to refresh google map using ajax by fetching lat long from database
how to refresh google map using ajax by fetching lat long from database  i have a jsp page where we select the object and by submitting the form the route travelled by it will be displayed on the google map by fetching the lat
Java object's lock
Java object's lock  What is an object's lock and which object's have locks
java object - Java Beginners
java object  i want a complete memory description of objects,methods... of objects. The primitive data type and keyword void is work as a class object. Object: Object is the basic entity of object oriented programming language
java object - Java Beginners
java object  i want to where in the memory the java objects,local... are stayed  Hi friend, Instance Variables (Non-static fields): In object... fields" that is declared without the static keyword. Each object of the class has its
java object class methods
java object class methods  What are the methods in Object class?  There are lots of methods in object class. the list of some methods are as- clone equals wait finalize getClass hashCode notify notifyAll
Advertisements
 

 

 

DMCA.com