[jboss-user] [EJB 3.0] - @PostLoad invoked before eagerly loaded property finishes lo

JLuv do-not-reply at jboss.com
Tue Oct 10 23:18:00 EDT 2006


I have an entity which has a Map set to load eagerly.  When trying to access the map in a method annotated as PostLoad, I am getting a LazyInitializationException ("illegal access to loading collection") from AbstractPersistentCollection.java:341


  | /**
  | 	 * Initialize the collection, if possible, wrapping any exceptions
  | 	 * in a runtime exception
  | 	 * @param writing currently obsolete
  | 	 * @throws LazyInitializationException if we cannot initialize
  | 	 */
  | 	protected final void initialize(boolean writing) {
  | 		if (!initialized) {
  | 			if (initializing) {
  | 				throw new LazyInitializationException("illegal access to loading collection");
  | 			}
  | 			throwLazyInitializationExceptionIfNotConnected();
  | 			session.initializeCollection(this, writing);
  | 		}
  | 	}
  | 

Correct me if I am wrong, but I think a PostLoad method should not be fired until eagerly loaded properties are finished.  

In other words, listeners.onPostLoad(postLoadEvent) from TwoPhaseLoad.initializeEntity shouldn't be invoked until the "initializing" field in each of the entity's eagerly loaded AbstractPersistentCollection objects is set to false.

Any thoughts on whether this should be considered a bug?

How about any ideas for a workaround?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3977408#3977408

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3977408



More information about the jboss-user mailing list