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



Home Answers Viewqa Development-process Delete database Table through hibernate and Spring

Have Programming Question? Ask it here!
 
 
 


Yuvaraj
Delete database Table through hibernate and Spring
0 Answer(s)      3 years and 4 months ago
Posted in : Development process


Hi, I am using Spring,Hibernate and Tapestry to save and also fetch data simultaneously from mysql database.I am facing a problem,whenever i refresh the number of data saved and fetched is repeated all the time.Please give me a solution to get data only once without repetation,or Detete table after data is fetched.

Here is UserManagerImpl code: package tuto.webssh.service.impl;

import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import tuto.webssh.domain.dao.UserDao; import tuto.webssh.domain.model.Info; import tuto.webssh.service.UserManager;

public class UserManagerImpl implements UserManager {

  private final Log logger = LogFactory.getLog(UserManagerImpl.class);
  private UserDao userDao = null;

/**
  * setter to allows spring to inject userDao implementation
  * @param userDao : object (implementation of UserDao interface) to inject.
 */
   public void setUserDao(UserDao userDao) {
      this.userDao = userDao;
    }


public void getSave(Info info) {
   userDao.getSave(info);

}

 public List<Info> toRetrieve() {
   return userDao.getRetrieve();

} }

Here is class to Fetch data: package tuto.webssh.web.pages;

import java.util.List; import tuto.webssh.domain.model.Info; import tuto.webssh.service.UserManager; import org.apache.tapestry.annotations.Inject; import org.apache.tapestry.annotations.Persist; import org.apache.tapestry.annotations.Service;

public class Fetch { @Inject @Service("userManager") private UserManager userManager;

@Persist
private List<Info> info;

 public List<Info> getInfo() {
        fetch();
        return info;
    }

    public void setInfo(List info) {
        this.info = info;
        }

    public void fetch()
    {
        String str="fetched data";
        List<Info> tempInfo = userManager.toRetrieve(); 
        info=tempInfo;
    }

}

Here is UserDaoImpl code: package tuto.webssh.domain.dao.hibernate3; import java.util.List;

import tuto.webssh.domain.model.Info; import tuto.webssh.domain.dao.UserDao; import org.hibernate.Session; import org.hibernate.Criteria; import org.hibernate.Transaction; import org.springframework.dao.DataAccessException; import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class UserDaoImpl extends HibernateDaoSupport implements UserDao {

public UserDaoImpl() { // TODO Auto-generated constructor stub } public void getSave(Info info) { try{ Session sess = getHibernateTemplate().getSessionFactory().getCurrentSession(); Transaction tx = sess.beginTransaction(); sess.save(info); tx.commit(); }

      catch(DataAccessException e)
      {
          e.printStackTrace();
      }

} public List<Info> getRetrieve(){

            Session  session = getHibernateTemplate().getSessionFactory().getCurrentSession();
             session.beginTransaction();
             Criteria crit = session.createCriteria(Info.class);
             List<Info> info=crit.list();
             return info;    
                            }

}

Here is class for Table(Info) in MySQL database with database name Json: package tuto.webssh.domain.model;

// Generated Feb 23, 2011 5:19:45 PM by Hibernate Tools 3.4.0.CR1

import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import static javax.persistence.GenerationType.IDENTITY; import javax.persistence.Id; import javax.persistence.Table;

/** * Info generated by hbm2java */ @Entity @Table(name = "info", catalog = "json") public class Info implements java.io.Serializable {

private Integer id;
private String names;
private String images;
private String heading;
private String type;

public Info() {
}

public Info(String names, String images, String heading, String type) {
    this.names = names;
    this.images = images;
    this.heading = heading;
    this.type = type;
}

@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
    return this.id;
}

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

@Column(name = "names", nullable = false, length = 25)
public String getNames() {
    return this.names;
}

public void setNames(String names) {
    this.names = names;
}

@Column(name = "images", nullable = false, length = 25)
public String getImages() {
    return this.images;
}

public void setImages(String images) {
    this.images = images;
}

@Column(name = "heading", nullable = false, length = 25)
public String getHeading() {
    return this.heading;
}

public void setHeading(String heading) {
    this.heading = heading;
}

@Column(name = "type", nullable = false, length = 25)
public String getType() {
    return this.type;
}

public void setType(String type) {
    this.type = type;
}
}

This fetch and save is called by index.java and index.html pages to display.

Thank you,
With regards,
Yuvaraj.

Advertisement
View Answers

Related Tutorials/Questions & Answers:
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
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
Advertisements
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
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... [delete from CONTACT] int i=query.executeUpdate
Delete a Column from a Database Table
Delete a Column from a Database Table   ... to delete a column from a database table. We are not going to create a new table... the already created table in the specific database. Now if we want to delete
Delete row and column from table through java code
Delete row and column from table through java code... will see how to delete row and column from given table through java code. Java code...' and a table 'stu_info' in same database. Structure of table 'stu_info
spring hibernate
spring hibernate  I need to save registration details in a database table through jsp using spring an hibernate....and the fields in the registration... the following link: http://www.roseindia.net/hibernate/HibernateSpring.shtml
spring hibernate
spring hibernate  I need to save registration details in a database table through jsp using spring an hibernate....and the fields in the registration... the following link: http://www.roseindia.net/hibernate/HibernateSpring.shtml
how to make JTable to add delete and update sql database table
how to make JTable to add delete and update sql database table  Hello all I want to know how to make JTable to act actively to add delete and update database table. i am struck ed here from long time please help me
Spring MVC and Hibernate with DWR 3 -- Configuration Using MySQL Database
Spring MVC and Hibernate with DWR 3 -- Configuration Using MySQL Database  How to configure Spring MVC and Hibernate with DWR 3, Simple example -- reading a table, editing-deleting and adding new rows
how to send email list of email address through in database table list
how to send email list of email address through in database table list  package com.com; import java.io.IOException; import java.io.PrintWriter; import java.sql.PreparedStatement; import java.sql.ResultSet; import
JSF+SPRING+HIBERNATE - AOP
JSF+SPRING+HIBERNATE  any form builder is available from database table to UI FORM LIKE list ,add,edit,delete and search
Hibernate delete HQL - Hibernate
Hibernate delete HQL  Hi I am trying hibernate tutorial. But delete HQL tutorial not working properly. It gives null pointer exception. Query class has method executeUpate() & not executeUpdate
How to delete a table in mysql
How to Delete a Table in MySQL       Consider a situation where we need to delete a table from a database.  To delete a table from the database firstly we need
spring with hibernate - Spring
spring with hibernate   Hi, I need the sample code for user registration using spring , hibernate with my sql. Please send the code as soon as possible. I need Spring with Hibernate code not struts. Thanks, Valarmathi
spring hibernate spring
spring hibernate spring  why are all the links in the following page broken. http://www.roseindia.net/struts/hibernate-spring/integrate.shtml... the following link: Spring Hibernate Thanks
spring hibernate
spring hibernate  i need to display many fields( fields are in different tables) in a jsp page....how to implement this using spring hibernate  .../hibernate-spring/index.shtml
delete() method of hibernate
delete() method of hibernate  Define the use of delete() method of hibernate? Example
insert and delete data in database
insert and delete data in database  insert and delete data in database from servlets through JDBC   Hi Friend, Please visit the following links: Insert Data Delete Data Thanks
spring hibernate - Hibernate
with hibernate?  Hi friend, For solving the problem Spring with Hibernate visit to : http://www.roseindia.net/spring/index.shtml http://www.roseindia.net/struts/hibernate-spring/index.shtml Thanks
Hibernate criteria delete Example
Hibernate criteria delete Example  How to use the delete criteria in Hibernate? thanks
Hibernate criteria delete Example
Hibernate criteria delete Example  How to use the delete criteria in Hibernate? thanks
Hibernate Delete Query
database using the hibernate. Lets first write a java class to delete a row from... Hibernate Delete Query      ... (DeleteHQLExample.java), which we will delete a row from the insurance table using the query
spring with hibernate - Spring
spring with hibernate   Hi, I need the sample code for user registration using spring , hibernate with my sql. Please send the code as soon... the following link: http://www.roseindia.net/struts/hibernate-spring/user-registration
Struts Hibernate Spring - Hibernate
Struts Hibernate Spring  HI Deepak, This is reddy.i want expamle for struts hibernate spring example.  Hi Friend, Please visit the following link: http://www.roseindia.net/struts/hibernate-spring/index.shtml
Use of delete() method in hibernate.
Use of delete() method in hibernate.  Define the use of delete() method of hibernate?   Hibernate provide the facility to delete one row... department0_ where department0_.id=? Hibernate: delete from department where id
How can I paginate a table which has shown in a div through Ajax in client side without using database
How can I paginate a table which has shown in a div through Ajax in client side without using database   The table is shown by calculation in a PHP... the table
Integration Struts Spring Hibernate.
Integration Struts Spring Hibernate.  Integration Struts Spring Hibernate
delete query problem - Hibernate
delete query problem  SessionFactory fact = new Configuration... = sess. beginTransaction(); String hql = "delete from STUDENT where name = 'mitha... system properly. STUDENT is not mapped. [delete from STUDENT where name = 'mitha
Hibernate delete example program
Hibernate delete example program  How to delete an object in Hibernate? In my program I have to write program to delete the data using Hibernate framework. I want to delete one row of data who's primary key is known to me. What
Delete points from database
Delete points from database  I have a polygon on a web page and a delete button. The polygon is saved in the database in one table and in another table, the coordinates of polygon (latitude,longitude) are saved. When I click
Spring wit hibernate - Spring
Spring wit hibernate  when i m trying to access the data using spring with hibernate DAo framwork, i m geeting session closed exception. some thing like this org.hibernate.LazyInitializationException: could not initialize proxy
SPRING WITH DATABASE
SPRING WITH DATABASE  I need any Spring MVC project that connects with oracle database. I need step by step code description and explanation.I want how to create spring project and how to connect with the oracle database. I need
Delete a Specific Row from a Database Table
Delete a Specific Row from a Database Table   ... from a specific database table. Here is an example with code which provides the facility for deleting specific row in a database table. Sometimes, you want
Navigation in a database table through jsp
Navigation in a database table through jsp  ... :- mysql> create database student; Then create a table named 'stu_info' in the same database through following sql query :- create
hibernate delete query :
hibernate delete query :   Hi, I m using Hibernate 3 + javadb my table is like: CREATE table APP.BIDS ( BID_ID INTEGER NOT NULL... NOT NULL , ITEM_ID INTEGER NOT NULL ) I want to delete a row from table
apache cxf+hibernate+spring
apache cxf+hibernate+spring  how to connect to the database(here am using hibernate+spring)from apache cxf(contract-last).pls provide directory structure
spring mvc3 and hibernate with annotation example
spring mvc3 and hibernate with annotation example  please send an example which is used to store the form data into database using spring with hibernate using annotations
delete an item from database
delete an item from database  how to delete an item from the database using jsp
Delete a Records in Database
from the table. The generalized Syntax  used for delete query in database... to delete Records in Database. In this Tutorial, we create a table country, in which we... Delete a Records in Database   
myfaces,hibernate and spring integration - Hibernate
myfaces,hibernate and spring integration  sorry, in the previous... folder) to my tomcat/webapp directory. 4)i have created the database and corresponding table in mysql. 5)have done changes in the HibernateMyfaces\WEB-INF
sqlite database delete row
sqlite database delete row  How to delete row from SQLite Database?    NSString *updateSQL = [NSString stringWithFormat: @"DELETE FROM aListDB WHERE id='%@'",details.ids
Hibernate delete a row error - Hibernate
Hibernate delete a row error  Hello, I been try with the hibernate delete example (http://www.roseindia.net/hibernate/hibernate-delete.shtml...(); //======================================= sess = fact.openSession(); String hql = "delete from Contact contact
how to login form through spring dao module
how to login form through spring dao module  here i want to chek user details in database through form by using spring dao module.please give me some reference example to me
Spring with Hibernate - Spring
Spring with Hibernate  When Iam Executing my Spring ORM module (Spring with Hibernate), The following messages is displaying on the browser window HTTP Status 500
Integrating JSF Spring and Hibernate
Integrating JSF Spring and Hibernate           Integrating JSF, Spring and Hibernate This article explains integrating JSF (MyFaces), Spring and Hibernate to build real
 

 

 

DMCA.com