These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: can you see this code help me
PostPosted: Thu Dec 15, 2005 3:32 am 
Newbie

Joined: Thu Dec 15, 2005 1:05 am
Posts: 4
Location: secundrabad
Need help with Hibernate? Read this first:


here we developed for crud orerations but we are hard coded for onetable but i want to display all tables in db and if you select any one of them accoding to that one we can perform oerations. please help me anybody knows generalization concept

here i given clear view



The performance of the hibernate is high because of using the following technologies
A fetching strategy is the strategy Hibernate will use for retrieving associated objects if the application needs to navigate the association. Fetch strategies may be declared in the O/R mapping metadata, or over-ridden by a particular HQL or Criteria query.
POC:

This application is user friendly for inserting, deleting and updating data through the GUI.

This application is developed using struts and hibernate frameworks in this application all Action forms, Action class and all forms like insert, update, delete, main, success and failure all these are developed using struts framework

Here we developed one interface IselectTable.java in this we declare the methods like getFields, insert, delete, getRows.

Above said all these methods are implemented in SelectTableImpl.java this class is developed using the hibernate.

In Database we created the table with the name “Example Table” with columns Id as number (4) and Name as varchar2 (10).

Application Flow:

The application is developed and saved it is named as Ebase

First open the Internet browser and type http://localhost: 8080/ebase/main.jsp you will get the form like select
The Reference table and Select the option to be perform with combo boxes you can
Select


Here we developed all forms like insert, delete, update, successes and failure forms are developed using jsp’s. With struts framework.

All Action Forms and Action Class are developed using using struts framework.

Here we developed one interface Selectable in this we declare some methods like insert, update, delete, getfields, getnames, getrows etc
All these methods are implemented in selectTableimpl
Select Table impl class first we assign session factory to null and we have written a default constructor
We have developed init methods in this method we creating session factory. Session Factory creates Sessions. Usually an application has a single Session Factory. Threads servicing client requests obtain Sessions from the factory.
Implementers must be thread safe. SessionFactorys are immutable. The behavior of a Session Factory is controlled by properties supplied at configuration time. These properties are defined on Environment


An instance of Configuration allows the application to specify properties and mapping documents to be used when creating a Session Factory. Usually an application will create a single Configuration, build a single instance of Session Factory and then instantiate Sessions in threads servicing client requests. The Configuration is meant only as an initialization-time object. SessionFactorys are immutable and do not retain any association back to the Configuration

Here we developed one method insert like public Boolean insert (Table t)

In hibernate we require session object to perform the data base operation .to create session object we require session factory object.

To create session factory object we require configuration object. The configuration object is responsible for reading the information available 8incfg.xml and hibernates. xml

In this method we open the session and create the date base connection using
Session session=sessionFactory.openSession ();

Here we begin the transaction using the method like Transaction txt=session.beginTransaction ();

Allows the application to define units of work, while maintaining abstraction from the underlying transaction implementation (e.g. JTA, JDBC).
A transaction is associated with a Session and is usually instantiated by a call to Session.beginTransaction (). A single session might span multiple transactions since the notion of a session (a conversation between the application and the data store) is of coarser granularity than the notion of a transaction. However, it is intended that there be at most one uncommitted Transaction associated with a particular Session at any time.

Session. Save (t); save the values to the database

In session object the methods like save, load, update, delete available in session using this methods we can perform database operations.
Txt. commit ();
Session. Close ();
Using these two statements txs is committed and session is closed. Return true if the transaction is success otherwise false.
Like that delete and update operations are there
Here one more method is there like

Public java.util.List getRows ()
Using this we can get how many rows are there that particular table like
Session session=sessionFactory.openSession ();
Transaction txt=session.beginTransaction ();
Using these two statements we can open the session and begin the transaction.

Query q=session.createQuery ("from fom.ebaseindia.valuesys.handling_data.tables.actions.Table");
Using this statement create instance of query using this query we can get how many rows are there that particular table.

Java.util.List list=q.list ();

All these are stored in above statement and return list.

Like that all these methods are developed

Control Flow

First open the Internet browser and type http://localhost: 8080/ebase/main.jsp

You can get main’s in this The Reference table and Select the option to be perform with combo boxes you can Select whatever you want if select insert and table is Example Table. You will get that particular table insert form know we can select and submit

Here we developed one select table form and selectTableAction class using these class that particular forms forms will be displayed.

This we developed InsertTableForm, Insert Table Action .in from we developed setxxx and getxx functions for particular fields in action class all these fields are stored in to the table
In action class we written the execute method
Public ActionForward execute (ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
Throws Exception {
And creates the objects for action errors and Action forwards
ActionErrors errors = new ActionErrors (); // for errors
ActionForward forward = new ActionForward (); // return value

Next open the try block in this InsertActionForm is Typecasts into particular form like that

InsertTableForm stForm=(InsertTableForm) form;


String name = stForm.getName ();
We create the table objectlike that Table t=new Table ();
And set to the
t.setName(name);
in this class we create the object for ISelectTable ist=new SelectTableImpl ();
SelectTableImpl () we have one method call insert through this method we can insert these values.
public boolean insert(Table t){

try{
Session session=sessionFactory.openSession();
Transaction txt=session.beginTransaction();
session.save (t);
txt.commit();
session.close();
return true;
} catch(Exception e){
e.printStackTrace ();
return false;
}

In this method we open the created the session object


Transaction txt=session.beginTransaction(); Using this object we begin the transaction

And do the whatever operation s we required if the txs is successful txs is committed other wise rollback



Boolean flag=ist.insert (t);
if (flag)
return mapping.findForward ("insert");
Return mapping.findForward ("fail");

if it is insert return insert this will print insert successes other wise failure

Catch (Exception e){
e.printStackTrace ();
Errors.add ("error", new Action Error ("errorID"));

if any errors occurs exceptions will be thrown using above statements like that we developed using hibernate

if we select the operation is delete Form is displayed in this display from display all rows from the particular table. To get all rows we developed one method call getRows
public java.util.List getRows(){

Session session=sessionFactory.openSession();
Transaction txt=session.beginTransaction();
Query q=session.createQuery("from com.ebaseindia.valuesys.handling_data.tables.actions.Table");
java.util.List list=q.list();
txt.commit();
session.close();
System.out.println(((Table)list.get(0)).getNumber());
return list;

}

In this method we create the session object and begin the transaction

Query q=session.createQuery ("from com.ebaseindia.valuesys.handling_data.tables.actions.Table");

Using this query we can get the all the rows from data base .
All these are stored into the list.and again commit the txs and close the session.

In delete .jsp we can get these rows using these statements



<form action="delete.do">
<select name="rowID">
<%
java.util.List l=(java.util.List)session.getAttribute("tableFields");

for(int i=0;i<l.size();i++)
{
%>
<option>
<%
out.println( ((com.ebaseindia.valuesys.handling_data.tables.actions.Table)l.get(i)).getNumber());
%>
</option>
<%
}
%>
</select>
Using above statements we can get all these rows displaying in combo boxes

If user select the particular row and submit it will go the deletetableActionform and action class that action class delete the particular row through the delete method in the selecttableimpl class that delete method is like that
public boolean delete(Table t,int n){
Session session=sessionFactory.openSession ();
Transaction txt=session.beginTransaction();
session.load(t,new Integer(n));
session.delete(t);
txt.commit();
session.close();
return true;
}

session.load method is executed hibernate issues the select statement on db get the data from the database and stores the data into object
session.delete(t);

this statement will delete the particular row and TX will be committed
According to the txs the action class will display success or failure.

Like that update also work





IselectTable.java

package com.ebaseindia.valuesys.handling_data.tables;
import com.ebaseindia.valuesys.handling_data.tables.actions.Table;
public interface ISelectTable
{
public java.util.List getFields(String table,int number)throws Exception;
public boolean insert(Table table)throws Exception;
public java.util.List getRows()throws Exception;
public boolean delete(Table table,int n)throws Exception;
public boolean update(Table table,int number)throws Exception;

}


SelectTableImp.java



package com.ebaseindia.valuesys.handling_data.tables.actions;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Query;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import com.ebaseindia.valuesys.handling_data.tables.ISelectTable;
public class SelectTableImpl implements ISelectTable
{
SessionFactory sessionFactory=null;
public SelectTableImpl(){
super();
init();
}
public void init(){

try{
sessionFactory = new Configuration().configure().buildSessionFactory();
}catch(Exception e){
e.printStackTrace();
}
}
public java.util.List getFields(String tableName,int number){
Session session=sessionFactory.openSession();
Transaction txt=session.beginTransaction();
Query q=session.createQuery("from com.ebaseindia.valuesys.handling_data.tables.actions.Table" +" tab where tab.number="+number);
java.util.List list=q.list();
txt.commit();
session.close();
System.out.println(((Table)list.get(0)).getNumber());
System.out.println(((Table)list.get(0)).getName());
return list;
}
public boolean insert(Table t){

try{
Session session=sessionFactory.openSession();
Transaction txt=session.beginTransaction();
session.save(t);
txt.commit();
session.close();
return true;
}catch(Exception e){
e.printStackTrace();
return false;
}

}
public java.util.List getRows(){

Session session=sessionFactory.openSession();
Transaction txt=session.beginTransaction();
Query q=session.createQuery("from com.ebaseindia.valuesys.handling_data.tables.actions.Table");
java.util.List list=q.list();
txt.commit();
session.close();
System.out.println(((Table)list.get(0)).getNumber());
return list;
}
public boolean update(Table t,int number){
try{
Session session=sessionFactory.openSession();
Transaction txt=session.beginTransaction();
session.update(t,new Integer(number));
txt.commit();
session.close();
return true;
}catch(Exception e){
e.printStackTrace();
return false;
}
}

public boolean delete(Table t,int n){
Session session=sessionFactory.openSession();
Transaction txt=session.beginTransaction();
session.load(t,new Integer(n));
session.delete(t);
txt.commit();
session.close();
return true;
}


}


Table.java



ackage com.ebaseindia.valuesys.handling_data.tables.actions;
public class Table
{
public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
public void setNumber(int number){
this.number=number;
}
public int getNumber(){
return number;
}
private String name;
int number;
}


SelectTableForm.java


package com.ebaseindia.valuesys.handling_data.tables.forms;
import org.apache.struts.action.ActionForm;
public class SelectTableForm extends ActionForm
{
public void setTableName(String tableName){
this.tableName=tableName;
}
public String getTableName(){
return tableName;
}
public void setOperation(String operation){
this.operation=operation;
}
public String getOperation(){
return operation;
}
private String tableName,operation;
}




SelectTableAction.java



package com.ebaseindia.valuesys.handling_data.tables.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.actions.DispatchAction;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.ebaseindia.valuesys.handling_data.tables.ISelectTable;
import com.ebaseindia.valuesys.handling_data.tables.forms.InsertTableForm;
import com.ebaseindia.valuesys.handling_data.tables.forms.SelectTableForm;

public class SelectTableAction extends DispatchAction
{
public ActionForward insert(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

ActionErrors errors = new ActionErrors(); // for errors
ActionForward forward = new ActionForward(); // return value
String target="fail";

System.out.println("before try");

try{

SelectTableForm stForm=(SelectTableForm)form;
HttpSession session = request.getSession();
String tableName = stForm.getTableName();
session.setAttribute("tableName",tableName);

ISelectTable ist=new SelectTableImpl();
java.util.List tableFields=ist.getRows();
int max=0;
for(int i=0;i<tableFields.size();i++){
if( max<((Table)tableFields.get(i)).getNumber())
max=((Table)tableFields.get(i)).getNumber();
}
session.setAttribute("id",new Integer(max+1));
//session.setAttribute("tableFields",tableFields);

return mapping.findForward("insert");

}catch(Exception e){
System.out.println("in cathc");
e.printStackTrace();
errors.add("error",new ActionError("errorID"));
}
forward=new ActionForward(target);
return forward;
}
public ActionForward update(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ActionErrors errors = new ActionErrors(); // for errors
ActionForward forward = new ActionForward(); // return value
String target="fail";

System.out.println("before try");
try{

SelectTableForm stForm=(SelectTableForm)form;
HttpSession session = request.getSession();
String tableName = stForm.getTableName();
session.setAttribute("tableName",tableName);

ISelectTable ist=new SelectTableImpl();
java.util.List tableFields=ist.getRows();
session.setAttribute("tableFields",tableFields);

return mapping.findForward("update");

}catch(Exception e){
System.out.println("in cathc");
e.printStackTrace();
errors.add("error",new ActionError("errorID"));
}
forward=new ActionForward(target);
return forward;

}
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

ActionErrors errors = new ActionErrors(); // for errors
ActionForward forward = new ActionForward(); // return value
String target="fail";

System.out.println("before try");

try{

SelectTableForm stForm=(SelectTableForm)form;
HttpSession session = request.getSession();
String tableName = stForm.getTableName();
session.setAttribute("tableName",tableName);

ISelectTable ist=new SelectTableImpl();
java.util.List tableFields=ist.getRows();
session.setAttribute("tableFields",tableFields);

return mapping.findForward("delete");

}catch(Exception e){
System.out.println("in cathc");
e.printStackTrace();
errors.add("error",new ActionError("errorID"));
}
forward=new ActionForward(target);
return forward;
}


}




InsertTableForm.java



package com.ebaseindia.valuesys.handling_data.tables.forms;
import org.apache.struts.action.ActionForm;
public class InsertTableForm extends ActionForm
{
public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
public void setNumber(int number){
this.number=number;
}
public int getNumber(){
return number;
}
private String name;
private int number;
}



InsertTableAction.java



package com.ebaseindia.valuesys.handling_data.tables.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.ebaseindia.valuesys.handling_data.tables.forms.InsertTableForm;
import com.ebaseindia.valuesys.handling_data.tables.forms.SelectTableForm;
import com.ebaseindia.valuesys.handling_data.tables.ISelectTable;

public class InsertTableAction extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

ActionErrors errors = new ActionErrors(); // for errors
ActionForward forward = new ActionForward(); // return value
String target="error";

try{

InsertTableForm stForm=(InsertTableForm)form;

String name = stForm.getName();
// String number=stForm.getNumber();

Table t=new Table();
// t.setNumber(number);
t.setName(name);
ISelectTable ist=new SelectTableImpl();
boolean flag=ist.insert(t);
if(flag)
return mapping.findForward("insert");
return mapping.findForward("fail");

}catch(Exception e){
e.printStackTrace();
errors.add("error",new ActionError("errorID"));
}
forward=new ActionForward(target);
return forward;
}

}




DeleteTableForm.java



package com.ebaseindia.valuesys.handling_data.tables.forms;
import org.apache.struts.action.ActionForm;
public class DeleteTableForm extends ActionForm
{

public void setRowID(int number){
this.number=number;
}
public int getRowID(){
return number;
}

private int number;
}





DeleteTableAction.java


package com.ebaseindia.valuesys.handling_data.tables.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.ebaseindia.valuesys.handling_data.tables.forms.DeleteTableForm;
import com.ebaseindia.valuesys.handling_data.tables.ISelectTable;

public class DeleteTableAction extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

ActionErrors errors = new ActionErrors(); // for errors
ActionForward forward = new ActionForward(); // return value
String target="error";

try{

DeleteTableForm stForm=(DeleteTableForm)form;

int number = stForm.getRowID();

Table t=new Table();
ISelectTable ist=new SelectTableImpl();
boolean flag=ist.delete(t,number);
if(flag)
return mapping.findForward("delete");
return mapping.findForward("fail");

}catch(Exception e){
e.printStackTrace();
errors.add("error",new ActionError("errorID"));
}
forward=new ActionForward(target);
return forward;
}

}



UpdateTableAction.java




package com.ebaseindia.valuesys.handling_data.tables.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.ebaseindia.valuesys.handling_data.tables.forms.InsertTableForm;
import com.ebaseindia.valuesys.handling_data.tables.forms.SelectTableForm;
import com.ebaseindia.valuesys.handling_data.tables.ISelectTable;

public class UpdateTableAction extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

ActionErrors errors = new ActionErrors(); // for errors
ActionForward forward = new ActionForward(); // return value
String target="error";

try{

InsertTableForm stForm=(InsertTableForm)form;

String name = stForm.getName();
int number=stForm.getNumber();

Table t=new Table();
t.setNumber(number);
t.setName(name);
ISelectTable ist=new SelectTableImpl();
boolean flag=ist.update(t,number);
if(flag)
return mapping.findForward("update");
return mapping.findForward("fail");

}catch(Exception e){
e.printStackTrace();
errors.add("error",new ActionError("errorID"));
}
forward=new ActionForward(target);
return forward;
}

}


SelectDataAction.java

package com.ebaseindia.valuesys.handling_data.tables.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.ebaseindia.valuesys.handling_data.tables.forms.DeleteTableForm;
import com.ebaseindia.valuesys.handling_data.tables.ISelectTable;

public class SelectDataAction extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

ActionErrors errors = new ActionErrors(); // for errors
ActionForward forward = new ActionForward(); // return value
String target="error";

try{

DeleteTableForm stForm=(DeleteTableForm)form;
HttpSession session = request.getSession();

int number = stForm.getRowID();

Table t=new Table();
ISelectTable ist=new SelectTableImpl();
java.util.List tableFields=ist.getFields((String)session.getAttribute("tableName"),number);
session.setAttribute("tableFields",tableFields);
return mapping.findForward("display");
}catch(Exception e){
e.printStackTrace();
errors.add("error",new ActionError("errorID"));
}
forward=new ActionForward(target);
return forward;
}

}

example.hbm.xml




<?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="com.ebaseindia.valuesys.handling_data.tables.actions.Table" table="ExampleTable">

<!-- A 32 hex character is our surrogate key. It's automatically
generated by Hibernate with the UUID pattern. -->
<id name="number" type="int">
<column name="id"/>
<!-- <generator class="sequence">
<param name="sequence">exampletable_id_seq</param>
</generator> -->
<generator class="increment"/>
</id>

<!-- A cat has to have a name, but it shouldn' be too long. -->
<property name="name" column="name"/>
</class>

</hibernate-mapping>



<?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="com.ebaseindia.valuesys.handling_data.tables.actions.Table" table="ExampleTable">

<!-- A 32 hex character is our surrogate key. It's automatically
generated by Hibernate with the UUID pattern. -->
<id name="number" type="int">
<column name="id"/>
<!-- <generator class="sequence">
<param name="sequence">exampletable_id_seq</param>
</generator> -->
<generator class="increment"/>
</id>

<!-- A cat has to have a name, but it shouldn' be too long. -->
<property name="name" column="name"/>
</class>

</hibernate-mapping>



hibernate.cfg.xml



<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>

<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:oracle</property>
<property name="connection.user">scott</property>
<property name="connection.password">tiger</property>
<!-- Mapping files -->
<mapping resource="ExampleTable.hbm.xml"/>

</session-factory>

</hibernate-configuration>
delete.jsp


<html>
<body>
<form action="delete.do">
<select name="rowID">
<%
java.util.List l=(java.util.List)session.getAttribute("tableFields");

for(int i=0;i<l.size();i++)
{
%>
<option>
<%
out.println( ((com.ebaseindia.valuesys.handling_data.tables.actions.Table)l.get(i)).getNumber());
%>
</option>
<%
}
%>
</select>
<input type="submit" value="delete">
</form>


<!--
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<html:html>
<body>
<html:form action="delete">
<html:select property="rowID">

<logic:iterate name="tableFields" id="tf">
<html:option value='<bean:write name="tf" property="name"/>'>
<bean:write name="tf" property="name"/>
</html:option>
</logic:iterate>
</html:select>
<html:submit/>
</html:form>
</body>
</html:html>
-->


update.jsp

<html>
<body>
<form action="getData.do">
<select name="rowID">
<%
java.util.List l=(java.util.List)session.getAttribute("tableFields");

for(int i=0;i<l.size();i++)
{
%>
<option>
<%
out.println( ((com.ebaseindia.valuesys.handling_data.tables.actions.Table)l.get(i)).getNumber());
%>
</option>
<%
}
%>
</select>
<input type="submit" value="update">
</form>





Display.jsp



<html>
<body>
<form action="update.do">

<%
java.util.List l=(java.util.List)session.getAttribute("tableFields");

for(int i=0;i<l.size();i++)
{
out.println("<input type=hidden name=number value="+request.getParameter("rowID")+">");
out.println("Number : "+ ((com.ebaseindia.valuesys.handling_data.tables.actions.Table)l.get(i)).getNumber());
out.println("</br>Name : <input type=\"text\" name=\"name\" value="+((com.ebaseindia.valuesys.handling_data.tables.actions.Table)l.get(i)).getName()+"></br>");
}
%>
<input type="submit" value="update">
</form>
</body>
</html>




insrt.jsp


<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>

<html:html>
<body>
<html:form action="insert">
Number :<html:text property="number"/>
Name :<html:text property="name"/>
<html:submit/>
</html:form>
</body>
</html:html>





main.jsp


<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<html:html>
<body>
<html:form action="/main">
Select reference table name:
<html:select property="tableName">
<html:option value="exampletable">exampletable</html:option>
<html:option value="upc">upc</html:option>
<html:option value="instrument_type">instrument types</html:option>
</html:select> <br>
Select the option to be perform:
<html:select property="operation">
<html:option value="insert">Insert</html:option>
<html:option value="update">Update</html:option>
<html:option value="delete">Delete</html:option>
</html:select>
<html:submit value="Submit"></html:submit><html:reset value="Reset"></html:reset>
</html:form>
</body>
</html:html>



strutsconfig.xml


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>

<!-- Form Beans -->
<form-beans>
<form-bean
name="insertForm" type="com.ebaseindia.valuesys.handling_data.tables.forms.InsertTableForm">
</form-bean>
<form-bean
name="deleteForm" type="com.ebaseindia.valuesys.handling_data.tables.forms.DeleteTableForm">
</form-bean>
<form-bean
name="mainForm" type="com.ebaseindia.valuesys.handling_data.tables.forms.SelectTableForm">
</form-bean>

</form-beans>
<action-mappings>
<form-bean
name="updateForm" type="com.ebaseindia.valuesys.handling_data.tables.forms.UpdateTableForm">
</form-bean>
<action
path="/main"
type="com.ebaseindia.valuesys.handling_data.tables.actions.SelectTableAction"
name="mainForm"
validate="false"
scope="session"
parameter="operation">
<forward name="insert" path="/Insert.jsp"/>
<forward name="delete" path="/Delete.jsp"/>
<forward name="update" path="/Update.jsp"/>
<forward name="fail" path="/fail.jsp"/>
</action>
<action
path="/insert"
type="com.ebaseindia.valuesys.handling_data.tables.actions.InsertTableAction"
name="insertForm"
validate="false"
scope="session">
<forward name="insert" path="/ISuccess.jsp"/>
<forward name="fail" path="/fail.jsp"/>
</action>
<action
path="/delete"
type="com.ebaseindia.valuesys.handling_data.tables.actions.DeleteTableAction"
name="deleteForm"
validate="false"
scope="session">
<forward name="delete" path="/DSuccess.jsp"/>
<forward name="fail" path="/fail.jsp"/>
</action>
<action
path="/update"
type="com.ebaseindia.valuesys.handling_data.tables.actions.UpdateTableAction"
name="updateForm"
validate="false"
scope="session">
<forward name="delete" path="/USuccess.jsp"/>
<forward name="fail" path="/fail.jsp"/>
</action>

</action-mappings>
</struts-config>



http://www.hibernate.org/ForumMailingli ... AskForHelp



Hibernate version: 3.o

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:



Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.