Frameworks| Hibernate| Struts| JSF| JavaFX| Ajax| Spring| DOJO| JDO| iBatis| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
Writing Java Object (POJO) 
 

System authenticates the user against the database and if the credentials provided by user are correct then user is allowed to login to the system, otherwise appropriate message is displayed.

 

Writing Java Object (POJO)

                         

In the tutorial we are developing web application that will enable the new users to register online. Existing users can logon to the system. System authenticates the user against the database and if the credentials provided by user are correct then user is allowed to login to the system, otherwise appropriate message is displayed.

Hibernate Mapping Class

We have only one table into the database and we need one POJO class and the hibernate mapping file to map the login object to the database table. Here is the code for "Login.hbm.xml" mapping file:

 

 

 

<?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="false">

      <class  name="roseindia.dao.hibernate.Login"  table="login" >

    <id  name="id"
        type="java.lang.Integer"
        column="id"
    >
       <generator class="increment" />
    </id>

    <property
        name="loginid"
        type="java.lang.String"
        column="loginid"
        not-null="true"
        unique="true"
        length="20"
    />

    <property
        name="password"
        type="java.lang.String"
        column="password"
        not-null="true"
        length="20"
    />

     <property
        name="email"
        type="java.lang.String"
        column="email"
        not-null="false"
        length="30"
    />

    <property
        name="address"
        type="java.lang.String"
        column="address"
        not-null="false"
        length="60"
    />

      

  <property
        name="phno"
        type="int"
        column="phno"
        not-null="false"
        length="11"
    />

      
      </class>
      </hibernate-mapping>

Above file should be present in the project\WEB-INF\src\java\roseindia\dao\hibernate directory. 

POJO Class
Here is the code of Login.java POJO class:

package roseindia.dao.hibernate;

import java.io.Serializable;

public class Login implements Serializable {

    /** identifier field */
    private Integer id;

    /** persistent field */
    private String loginid;

    /** persistent field */
    private String password;
    
    /** persistent field */
    private String email;
    
    
    /** persistent field */
    private String address;
    
    
    /** persistent field */
    private int phno;

    /** full constructor */
    public Login(Integer id, String loginid, 

String password, String email, 

String address, int phno) {
        this.id = id;
        this.loginid = loginid;
        this.password = password;
        this.address = address;
        this.phno = phno;
        this.email = email;
    }

    /** default constructor */
    public Login() {
    }

    public Integer getId() {
        return this.id;
    }

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

    public String getLoginid() {
        return this.loginid;
    }

    public void setLoginid(String loginid) {
        this.loginid = loginid;
    }

    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

  public String getAddress() {
    return address;
  }

  public void setAddress(String address) {
    this.address = address;
  }

  public String getEmail() {
    return email;
  }

  public void setEmail(String email) {
    this.email = email;
  }

  public int getPhno() {
    return phno;
  }

  public void setPhno(int phno) {
    this.phno = phno;
  }

}

 Save the above code into project\WEB-INF\src\java\roseindia\dao\hibernate directory.

In this section we developed the POJO class and the mapping file for our project.

                         

» View all related tutorials
Related Tags: java c hibernate web error learning com configuration spring ide class j2ee frameworks jdbc data development ui ssis process framework

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

2 comments so far (
post your own) View All Comments Latest 10 Comments:

Hi,
i am getting an error called "Exception creating bean of class roseindia.web.struts.form.EventsForm: {1}" while i am trying to add a form more to the application.

I've modified struts-config.xml,Login.hbm.xml,appli...xml,created one form class, one action class, added two methods called "addevents()" "loadevents()" to the "dao" package.

How can i resolve the error?

Posted by krishna on Saturday, 06.23.07 @ 23:18pm | #20058

Hi Deepak,

What changes need to be done in application context and other necessary files if we need to use org.springframework.orm.hibernate3.support.HibernateDaoSupport; instead of org.springframework.orm.hibernate.support.HibernateDaoSupport;

Posted by Akash Borkar on Thursday, 03.15.07 @ 22:45pm | #11837

Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.