-->
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.  [ 2 posts ] 
Author Message
 Post subject: how can we pass update commands in hibernate
PostPosted: Wed Apr 07, 2004 6:28 am 
Beginner
Beginner

Joined: Wed Mar 24, 2004 8:43 am
Posts: 42
hi

how can we pass update commands to modify the existing record using hibernate sql,

i had tried as below showed.but did not work


error
nullpointer exception

here is the jsp file

<form method="POST" action="productupdate.action">
<%

some codes...
%>


<p align="center"><font color="#000000" size="6"><strong> Modify An Product </strong></font></p>
<div align="center">
<table width="80%" border="1">
<tr>
<td width="48%" bgcolor="#999999"> <div align="left">
<p><strong>Org ID</strong></p>
<p><strong>Org Name</strong></p>
</div></td>
<td width="52%"><p>
<input name="productid" type="text" size="35" disabled value="<%= oid%>">
</p>
<p>
<input name="name" type="text" size="35" value="<%= a%>">
</p></td>
</tr>
<tr>
<td bgcolor="#999999"> <div align="left"><strong>Product price</strong></div></td>
<td><input name="price" type="text" size="35"value="<%= b%>"></td>
</tr>

<tr>
<td bgcolor="#999999"> <div align="left"><strong>Product Amount</strong></div></td>
<td><input name="amount" type="text" size="35"value="<%= c%>"></td>
</tr>



productupdate.action=ProductModify

here is ProductModify class

public String getProductid() {
return title;
}

public void setProductid(String title) {
this.title = title;
}


public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}


public double getPrice() {
return price;
}

public void setPrice(double price) {
this.price = price;
}

public int getAmount() {
return amount;
}

public void setAmount(int amount) {
this.amount = amount;
}

public String doExecute() {
try {



Configuration cfg=new Configuration().addClass(test.hibernate.data.Order.class).addClass(test.hibernate.data.OrderItem.class).addClass(Product.class);

SessionFactory sf=cfg.buildSessionFactory();
Session sess=sf.openSession();
tx=sess.beginTransaction();

/Product event = new Product();
Product event = (Product)sess.load(test.hibernate.data.Product.class,title);
//event.setId(title);
event.setName(name);
event.setAmount(amount);
event.setPrice(price);

sess.saveOrUpdate(event);
sess.flush();
//s.close();
System.out.println(" success");

return SUCCESS;
} catch (HibernateException e) {
e.printStackTrace();

System.out.println(" sorry error");
return ERROR;
}
}
[/u]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 7:34 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Check the log to see what happen
Commit your transaction

_________________
Emmanuel


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

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.