RE: [Informa-developer] Hibernate lazy initialization exception
Status: Beta
Brought to you by:
niko_schmuck
From: Marco M. <mmi...@wa...> - 2005-02-11 16:22:16
|
Hello, Sorry for late relpy.. I have currently 240 items in my database.... I am using Informa-0.6.0 With MySql 4.1.1alpha I am using Hibernate PersistenceManager and poller to insert data Into the database. I have however written another standalone program to insert items Into my database. Below is the standalone code that I was using...(don't bother about the creation Of channel groups etc ,I did it only once and then I was retrieving channels From existing groups.. Here is a piece of code.. PersistenceManagerIF manager = new de.nava.informa.utils.manager.hibernate.PersistenceManager(); ChannelGroupIF myGroup = manager.getGroups()[0]; URL url = new URL("http://online.wsj.com/xml/rss/0,,3_7014,00.xml"); ChannelIF newChannel = manager.createChannel("US Business", url); manager.addChannelToGroup(newChannel, myGroup); java.util.Collection items = newChannel.getItems(); Object[] itemArray = items.toArray(); java.util.Arrays.sort(itemArray, new ItemComparator(true)); System.out.println("Getting news from Channel:" + channel.getTitle()); for(int i=0; i < itemArray.length; i++) { ItemIF item = (ItemIF)itemArray[i]; System.out.println("------------------------------------"); System.out.println("Title:" + item.getTitle()); System.out.println("------------------------------------"); manager.createItem(newChannel,item); } let me know if this code works in your webapp.... regards marco -----Original Message----- From: inf...@li... [mailto:inf...@li...] On Behalf Of Nick Goupinets Sent: 07 February 2005 17:20 To: inf...@li... Subject: [Informa-developer] Hibernate lazy initialization exception Hi everybody, I run into a problem which I seem to be unable to solve on my own. I am trying to implement news system for a Cocoon based portal. I created a new cocoon component that uses Informa's persistence manager for the CRUD operations on channels / news item. I use a single "global" group for keeping track of all the channels on the system. So far everything was going on nicely until I got into some basic stress testing. It looks like there are no troubles if a channel contains [0..2] news items (Item class). As long as there are 3+ items, PersistenceManager gives the following error on initialization: net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCo llection.java:201) at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollecti on.java:71) at net.sf.hibernate.collection.Set.toArray(Set.java:146) at de.nava.informa.utils.manager.hibernate.NonCachingPersistenceManager.ini tGroupCollections(NonCachingPersistenceManager.java:525) at de.nava.informa.utils.manager.hibernate.NonCachingPersistenceManager.get Groups(NonCachingPersistenceManager.java:506) at de.nava.informa.utils.manager.hibernate.NonCachingPersistenceManager.get Groups(NonCachingPersistenceManager.java:172) at de.nava.informa.utils.manager.hibernate.PersistenceManager.getGroups(Per sistenceManager.java:122) at ca.test.components.impl.ChannelManagerImpl.initialize(ChannelManagerImpl .java:451) Has anyone experienced this problem before? Any help is appreciated. I have the following setup: Windows XP SP2 Tomcat 5.0.19 Cocoon 2.1.5.1 Informa 0.6.0 Hibernate 2.1.7c MySQL 4.1.7 Thank you very much for your time. Sincerely, Nick. |