3

It was reproduced only once with following stacktrace

Caused by: java.lang.NullPointerException at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:119) at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65) at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35) at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:970) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1115) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)

Anyone has idea what can be reason?

Hibernate version is 3.2.7.GA

I am sure that reason is not in current query, for each list execute. Why can flush for current session fall? Is it can be prevented somehow?

7
  • 6
    Source code missing Commented Aug 6, 2013 at 7:13
  • 3
    I was unable to hack into your machine and remotely retrieve the code you were referring to. Can you give me a hand? Commented Aug 6, 2013 at 7:13
  • 1
    The classes referred to in the stacktrace are Hibernate internals, so why you would need to hack into anyones machine to retrieve that is beyond me. Which version of Hibernate being used would be nice to know though.. Commented Aug 6, 2013 at 7:17
  • Check Hibernate settings, if don't found problems there please send us code. Commented Aug 6, 2013 at 7:19
  • Hibernate version is 3.2.7.GA Commented Aug 6, 2013 at 7:20

1 Answer 1

1

Here is the method that produces the nullpointer (source: http://grepcode.com/file_/repo1.maven.org/maven2/org.hibernate/hibernate/3.2.6.ga/org/hibernate/event/def/AbstractFlushingEventListener.java/?v=source):

private void prepareEntityFlushes(EventSource session) throws HibernateException {

    log.debug("processing flush-time cascades");

    final Map.Entry[] list = IdentityMap.concurrentEntries( session.getPersistenceContext().getEntityEntries() );
    //safe from concurrent modification because of how entryList() is implemented on IdentityMap
    final int size = list.length;
    final Object anything = getAnything();
    for ( int i=0; i<size; i++ ) {
        Map.Entry me = list[i];
        EntityEntry entry = (EntityEntry) me.getValue(); //nullpointer here!
        Status status = entry.getStatus();
        if ( status == Status.MANAGED || status == Status.SAVING ) {
            cascadeOnFlush( session, entry.getPersister(), me.getKey(), anything );
        }
    }
}

The IdentityMap.concurrentEntries returns an array of Map.Entry with the entries of the supplied map. Looks like there is a null-element returned in the map from session.getPersistenceContext().getEntityEntries(), try to get the source code (should be possible through most IDEs) and debug the method. Also, go through your entity definitions, might be something wrong there..

Sign up to request clarification or add additional context in comments.

4 Comments

Probably something related with his classes fields. Have a look at this.
Really easy with Maven to have a look at the sources ;-) BTW, the link Tobb provided is one version below, the one you need for the sources is this. Don't think it should be relevant.
Thank you, problem is really in this line EntityEntry entry = (EntityEntry) me.getValue(); But debug is not help in this situation, because exception was only once, and I try to reproduce this issue a lot of time after, but all was OK.
If it's not a problem anymore I wouldn't spend to much time trying to figure it out. Might just be a random fluke..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.