-->
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: Found two representations of same collection Error
PostPosted: Tue Jun 10, 2008 5:40 am 
Newbie

Joined: Thu Jun 05, 2008 11:45 pm
Posts: 6
Hi,
I am new to Hibernate and was facing lazyinitialization problems. To fix this I started using OpenSessionInViewFilter. I wrote my own filter which extends OpenSessionInViewFilter. For each request I am creating a session and closing it at the end. Due to this a new error has started occuring.

'org.hibernate.HibernateException: Found two representations of same collection'.

I am not sure why this is happening. Probably the method I have to used to resolve lazyinitialization itself is wrong. Could anyone please help me with it? Any ideas on the lazy initialization problem or the current problem would be greatly appreciated.

I have given below the code I have written for Session Filter.

Thanks & Regards
Ajay

-----------
/*
* The default mode is FlushMode.NEVER
*
* @see org.springframework.orm.hibernate.support.OpenSessionInViewFilter#getSession(net.sf.hibernate.SessionFactory)
*/
protected Session getSession(SessionFactory sessionFactory)
throws DataAccessResourceFailureException {
Session session = super.getSession(sessionFactory);
session.setFlushMode(FlushMode.COMMIT);
return session;
}

/**
* we do an explicit flush here just in case we do not have an automated flush
*/
protected void closeSession(Session session, SessionFactory factory) {
session.flush();
super.closeSession(session, factory);
}


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.