• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

update query not executing stale link error plz help

 
Rajeswari Gopal
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

this is my following code
.hbm
-----
<?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 package="com.table">
<class name="Details" table="Details">
<id name="id" type="int" column="userid" >
<generator class="native"/>
</id>
<property name="userName" column="username"/>
<property name="firstName" column="firstname"/>
<property name="lastName" column="lastname"/>
</class>
</hibernate-mapping>
html
----
<html>
<body jwcid="@Body">
<form jwcid="@Form" listener="listener:update" stateful="'false'">
<table jwcid="@Foreach" source="ognl:content" value="ognl etail" element="table">
<tr>
<td>Userid</td><td><span jwcid="@TextField" value="ognl etail.id" size="20"/></td>
</tr>
<tr>
<td>Username</td><td><span jwcid="@TextField" value="ognl etail.userName" size="20"/></td>
</tr>
<tr>
<td>First Name</td>
<td><span jwcid="@TextField" value="ognl etail.firstName" size="20"/></td>
</tr>
<tr>
<td>Last Name</td>
<td><span jwcid="@TextField" value="ognl etail.lastName" size="20"/></td>
</tr>
<tr><td></td><td><input type="submit" value="Save"/></td></tr>
</table>
</form>
</body>
</html>
java
----
public void update(IRequestCycle cycle)
{
Session session = null;
try
{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
session.beginTransaction();
detail.setId(id);
detail.setUserName(username);
detail.setFirstName(firstname);
detail.setLastName(lastname);
session.update(detail);
session.getTransaction().commit();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
if(session!=null)
{
session.flush();
session.close();
}
}
detail=new Details();
}

Here when i click submit button the stale link error is coming..
Whether the query is not correct..

following is the error
-----------------------
You have clicked on a stale link.

Rewind of form Update/$Form expected 3 more form elements, starting with id 'TextField'.

This is most likely the result of using your browser's back button, but can also be an application error.

You may continue by returning to the application's home page.


anybody please give me any idea..
thanks,
Raji
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this has nothing to do with hibernate or any other ORM technology. this is a tapestry problem so better try another forum.
or try seearching: http://www.google.ch/search?q=tapestry+stale+link&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US fficial
(or similar)


and by the way:

- a SessionFactory and Configuration are expensive Objects (in terms of resources / construction time). you do not want to recreate them upon each request. better keep a reference to the SF and just open a session
- you do not call rollback when operation fails. check out the hibernate reference documentation how a correct try/catch/finally block should look like
- if you close() the Session, then you do not need to flush() it.


cheers

pascal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic