-->
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: Attached / Detached...
PostPosted: Thu Mar 21, 2013 8:59 pm 
Newbie

Joined: Wed Feb 27, 2013 2:59 pm
Posts: 6
Hi, I have a questions..

EAR
- War
- EJB

War is a GWT application.
In the GWT I Inject a interface for a StatelessSessionBean.

Code:
@EJB
private PrintProviderMockSBBeanLocal ppmockSBBeanLocal;


The PrintPoviderSessionBean loads some data from the database.
Code:
@Override
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public ArrayList<PrintProviderMockEnt> getPrintProviders() throws BusinessException, SystemException {
   Query query = manager. createQuery("from PrintProviderMockEnt");
   ArrayList<PrintProviderMockEnt> resultList = (ArrayList<PrintProviderMockEnt>) query.getResultList();
   return resultList;
}


and gets returned to the GWT class..
Here I call some methods on the objects... and get a

Quote:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role


But shouldn't the objects been detached by now ???

I also tried this...

Code:
@Override
   @TransactionAttribute(TransactionAttributeType.SUPPORTS)
   public ArrayList<PrintProviderMockEnt> getPrintProviders() throws BusinessException, SystemException {
      Query query = manager.createQuery("from PrintProviderMockEnt");
      ArrayList<PrintProviderMockEnt> resultList = new ArrayList<PrintProviderMockEnt>();
      ArrayList<PrintProviderMockEnt> tmp = (ArrayList<PrintProviderMockEnt>) query.getResultList();
      for (PrintProviderMockEnt printProviderMockEnt : tmp) {
         manager.detach(printProviderMockEnt);
         resultList.add(printProviderMockEnt);
      }
      return resultList;
   }


But I still get the
org.hibernate.LazyInitializationException:


Top
 Profile  
 
 Post subject: Re: Attached / Detached...
PostPosted: Fri Mar 22, 2013 1:19 pm 
Newbie

Joined: Wed Feb 27, 2013 2:59 pm
Posts: 6
I even try to close the session...

Code:
@Override
   @TransactionAttribute(TransactionAttributeType.SUPPORTS)
   public ArrayList<PrintProviderMockEnt> getPrintProviders() throws BusinessException, SystemException {
      Query query = manager.createQuery("from PrintProviderMockEnt");
      ArrayList<PrintProviderMockEnt> resultList = new ArrayList<PrintProviderMockEnt>();
      ArrayList<PrintProviderMockEnt> tmp = (ArrayList<PrintProviderMockEnt>) query.getResultList();
      for (PrintProviderMockEnt printProviderMockEnt : tmp) {
         manager.detach(printProviderMockEnt);
         resultList.add(printProviderMockEnt);
      }
      Session session = manager.unwrap(Session.class);
      session.close();
      return resultList;
   }


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.