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

 
 


Yuvaraj
Delete database Table through hibernate and Spring
0 Answer(s)      2 years and 3 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.
View Answers









Related Pages:
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
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
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
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
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
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
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
delete
delete  how delete only one row in the database using jsp.database...;br> <table border="1"> <tr><th>Emp ID</th><th>... type="button" name="edit" value="Delete" style="background-color:red;font-weight
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
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
Hibernate delete Query
Hibernate delete Query In this tutorial you will learn how to use HQL delete query in Hibernate. In this section we are discussing about the HQL delete query... query is used to delete the fields, field records, table, etc. In our example we
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
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
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
redeploy project update database table
redeploy project update database table  **Dear Sir, i am using Hibernate 3.3 and spring 3.0 and mysql database. Now while redeploying project In tomcat 6 i want to run a sql query Thanks for your wise comments
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
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
Delete a column
Delete a column       In this section, you will learn how to delete a column from database table using jpa. You need the following artifacts: Database table: student Model
myJSF,Hibernate and Spring integration code is not working. - Hibernate
myJSF,Hibernate and Spring integration code is not working.  the code... created the database and corresponding table in mysql. 5)have done changes in the HibernateMyfaces\WEB-INF\jdbc.properties file to point to my local database. 6
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
Deleting All Rows From the database Table
helps us to write on the browser. To delete all the rows from our database table... From the database Table      ... after sometime . Rather than go through with that data its better to delete
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
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   
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
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
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
Complete Hibernate 4.0 Tutorial
data from Java environment to database table. Persistence is a storing ... to this table. Hibernate 4 was released in December 2011. The newly added features... Hibernate Update Query Hibernate Delete Query
database through jsp
database through jsp  sir actually i want to retrieve the data from database dynamically.because i dont know how many records... database and display it in html table. <%@ page import="java.sql.*" %> <
delete data from database - SQL
delete data from database  HOw to delete specific data from table> I want to delete one record from database. Thnx  Hi friend, -------------------------------------------- Visit for more information
Hibernate - Hibernate
Address join fetch City" How to connect these two table in different database...Hibernate   Dear sir Thanks for your previous answers its really help me a lot. This is my question : I had 2 application(Java, spring
Hibernate Delete Query
In this section we will discuss how to delete record of table using HQL
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
Spring - Spring
Spring  Hi How to select more than one table in hibernate. Sample join query in hql. With Regards Venkat
Integrating MyFaces , Spring and Hibernate
to configure Hibernate, Spring and MyFaces to use MySQL Database to  build real world...Integrating MyFaces , Spring and Hibernate   ..., let's start developing Login and Registration application using Hibernate, Spring
For CRUD application - Spring
For CRUD application  Hi, Can i have Crud(create ,edit,update,delete the data in database ) code & search the eployee using "id or name" using Spring ,Hibernate and Mysql Thanks Raghavendra
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
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
Access data from mysql through struts-hibernate integration
Access data from mysql through struts-hibernate integration  Hi... through struts-hibernate integration. My search command is working properly but my delete and insert command gives output correctly but they don't update mysql
DELETE
DELETE   I AM DOING IT IN MYSQL. DELETE FROM EMP WHERE SAL>(SELECT SAL FROM EMP WHERE ENAME='MILLAR') AND ENAME='ALLEN'; THIS IS GIVING THE FOLLOWING ERROR Error Code : 1093 You can't specify target table 'EMP
How to Delete a column and Add a new column to database
How to Delete a column and Add a new column to database   How to Delete a column and Add a new column to database   Hi, The following query is executed for add and delete a column in a table- for drop a column
Understanding Spring Struts Hibernate DAO Layer
in the database. Each table have their corresponding class hibernate and mapping are done... Understanding Spring Struts Hibernate DAO Layer... how Spring Hibernate and Struts will work together to provide best solution
hibernate criteria delete
hibernate criteria Delete In this Tutorial, We will discuss about hibernate... the values in the database table using mapping file. DataInsert.java package...(); } finally { session.close(); } } } The database table mapping
delete row
? localhost=wampserver database name=sourabh table name=sonu and my code...="delete" > <table width="100%" border="1"> <tr><td>...;   We are providing you the jsp code that displays the database table data
delete record
delete record  how to delete record using checkbox and button in php   We are providing you the jsp code that displays the database table data into the html table. Along each table row there is a checkbox consists

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.