Tissen,
Its not a good idea to try to solve this problem with synchronization.
That will cause other problems if you have multiple users. Try to
figure out the root cause of the errors you're encountering.
By any chance, does the Duplicate Mapping exception occur on the
second request when you start your app against an empty database? (no
tables, and hibernate is auto-creating the tables). If that is so, you
could try ensuring that Hibernate has an opportunity to initialize
(create tables) before the first browser request is handled. You can
do that with a ServletContextListener.
Chris.
On Dec 1, 2008, at 6:55 PM, Tissen wrote:
Dear All,
I am using Stripes for last 5months. Now I came across a situation
to make the action call synchronized as I am getting some weird
exception from hibernate while populating object using HQL.
Errors are not static. Some times its gives Duplicate Mapping
exception, Sometimes it gives Mapping Exception. Sometimes methods
gives proper result.
The Situation is, I have 4 iframes in one jsp and the url of these
iframe is to same action class with different action method by
passing different values. But DAO method is same in these action
methods.
These methods works fine if I call these methods one by one. But
when I use iframes the request to these actions are happening at the
same time them methods throws exception.
I tried with synchronized block/synchronized method at DAO service
level but the error is same. I reckon this can be solved by making
these request synchronized in action.
Did anybody come across any situation like this? Can anyone tell me
how to make the this action in single thread model? Or Can anyone
suggest something on this situation?
Here is my implementation.
In my jsp.
---
<IFRAME SRC="Form.action?techPortal" WIDTH=100% frameborder="0"></
IFRAME>
---
<IFRAME SRC="Form.action?warrantryPortal" WIDTH=100%
frameborder="0"></IFRAME>
---
<IFRAME SRC="Form.action?pubPortal" WIDTH=100% frameborder="0"></
IFRAME>
---
<IFRAME SRC="Form.action?miscPortal" WIDTH=100% frameborder="0"></
IFRAME>
----
FormAction.class
----
---
public Resolution techPortal() {
this.docs =
FormDAOFactory.createFormsDAO().loadByCategory(1l);
return new ForwardResolution("documentTree.jsp");
}
public Resolution warrantryPortal() {
this.docs =
FormDAOFactory.createFormsDAO().loadByCategory(2l);
return new ForwardResolution("documentTree.jsp");
}
public Resolution pubPortal() {
this.docs =
FormDAOFactory.createFormsDAO().loadByCategory(3l);
return new ForwardResolution("documentTree.jsp");
}
public Resolution miscPortal() {
this.docs =
FormDAOFactory.createFormsDAO().loadByCategory(4l);
return new ForwardResolution("documentTree.jsp");
}
---
---
DAO.
public List<Attachment> loadByCategoryTest(Long category) throws
DAOException {
List<Attachment> list;
Session session = null;
try {
session = HibernateUtil.getCurrentSession();
Query query = session.createQuery("select e from
Attachment e where e.category.id = :id order by e.type.id ");
list = query.setParameter("id", category).list();
} catch (Exception e) {
e.printStackTrace();
throw new DAOException(e.getMessage());
} finally {
session.flush();
session.close();
}
return list;
}
Attachment.xml
<hibernate-mapping>
<class name="au.com.toyota.aim.forms.domain.Attachment"
table="TBL_FORM_ATTACHMENT">
<id name="attachmentId" type="long" column="ATTACHMENT_ID">
<generator class="increment"/>
</id>
<property name="fileName">
<column name="FILE_NAME"/>
</property>
<property name="contentType">
<column name="CONTENT_TYPE"/>
</property>
<property name="title">
<column name="TITLE"/>
</property>
<property name="attachmentURL">
<column name="ATTACHMENT_URL"/>
</property>
<property name="content" update="false">
<column name="ATTACHMENT" sql-type="MEDIUMBLOB"/>
</property>
<many-to-one name="category" column="category_Id" foreign-
key="category_Id" lazy="false"/>
<many-to-one name="type" column="type_Id" foreign-
key="type_Id" lazy="false"/>
</class>
</hibernate-mapping>
--
Cheers,
Tissen Sebastian
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge
Build the coolest Linux based applications with Moblin SDK & win
great prizes
Grand prize is a trip for two to an Open Source event anywhere in
the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users