[Informa-developer] hibernate lazy initialization PersistenceManager.getGroups
Status: Beta
Brought to you by:
niko_schmuck
From: Scott D. <sc...@sw...> - 2005-08-29 02:58:05
|
Informa 0.6.0 MySQL Connector/J 3.1.8 I've written a very simple application to poll feeds and store them. There's no problem with creating the persistent channels and persisting their items using a Poller and PersistenceObserver. However, when I start my application a 2nd time, I don't want to recreate the group and channels. So, I'm trying to use PersistenceManager.getGroups(). However this doesn't work. -------------------------------------------------------- //First, try to get channels from DB. try { groups = manager.getGroups(); // <-- BLAM! Hibernate exception here!!! for (ChannelGroupIF group: groups) { logger.info("Loading channels from group: " + group.getTitle());// <-- NEVER get to this line. Collection<ChannelIF> c = group.getAll(); channels.addAll(c); } ///If we don't have any chanel groups, build them if (groups.length == 0) { -------------------------------------------------------- The heinous stack trace is below. I've stepped through the code with a debugger (using Netbeans 4.1...) and I see that my group is successfully created, but the exception occurs when trying to get the Collection of Channels. I've read the thread on this list about some column's being used to store serialized object, but I've looked at the ddl and the schema in MySQL and I don't see any such columns. It looks to me like the "default null" for the link column in the ITEM table is there, and that in fact all the rows have NULL value for that column. So, I don't think that's the problem. If anyone knows a way to successfully retrieve Channels from the DB, please let me know! Thanks, Scott --------------------------------------------------------------------- (collection.PersistentCollection 198 ) Failed to lazily initialize a collection net.sf.hibernate.type.SerializationException: could not deserialize at net.sf.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:197) at net.sf.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:220) at net.sf.hibernate.type.SerializableType.fromBytes(SerializableType.java:73) at net.sf.hibernate.type.SerializableType.get(SerializableType.java:38) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62) at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53) at net.sf.hibernate.type.AbstractType.hydrate(AbstractType.java:66) at net.sf.hibernate.loader.Loader.hydrate(Loader.java:611) at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:552) Aug 29, 2005 9:49:15 AM feedcatcher.FeedCatcher2 createChannels at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:511) at net.sf.hibernate.loader.Loader.getRow(Loader.java:426) at net.sf.hibernate.loader.Loader.doQuery(Loader.java:209) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:836) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:856) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51) at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:419) at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2106) at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1980) at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1942) at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:68) at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:232) SEVERE: Problem getting Channel Group from db! net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection at net.sf.hibernate.type.EntityType.nullSafeGet(EntityType.java:154) at net.sf.hibernate.collection.AbstractCollectionPersister.readElement(AbstractCollectionPersister.java:363) at net.sf.hibernate.collection.Set.readFrom(Set.java:233) at net.sf.hibernate.loader.Loader.readCollectionElement(Loader.java:305) at net.sf.hibernate.loader.Loader.doQuery(Loader.java:219) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:915) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:890) at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:83) at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284) at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3259) at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:195) at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71) at net.sf.hibernate.collection.Set.toArray(Set.java:146) at de.nava.informa.utils.manager.hibernate.NonCachingPersistenceManager.initGroupCollections(NonCachingPersistenceManager.java:522) at de.nava.informa.utils.manager.hibernate.NonCachingPersistenceManager.getGroups(NonCachingPersistenceManager.java:504) at de.nava.informa.utils.manager.hibernate.NonCachingPersistenceManager.getGroups(NonCachingPersistenceManager.java:170) at de.nava.informa.utils.manager.hibernate.PersistenceManager.getGroups(PersistenceManager.java:122) at feedcatcher.FeedCatcher2.createChannels(FeedCatcher2.java:88) at feedcatcher.FeedCatcher2.<init>(FeedCatcher2.java:58) at feedcatcher.FeedCatcher2.main(FeedCatcher2.java:79) |