JPAContainer NPE when refreshItem is called

Hello,

I have a little problem, I have a table displaying data from my database with the jpacontainer addon.

Everything works really well.

But I am updating some data somewhere else.

If I refresh the browser updated values are well updated in the table. But I have to force refresh without using F5 key :wink:

So I created something like this :

public void refresh()
	{
		for(Object itemId : container.getItemIds())
		{
			container.refreshItem(container.getItem(itemId));
		}
	}

And it failed, and generate an null pointer exception :

Caused by: java.lang.NullPointerException
	at com.vaadin.addon.jpacontainer.JPAContainer.refreshItem(JPAContainer.java:1649)
	at MyTable.refresh(MyTable.java:168)
	at MyGui$1.buttonClick(MyGui.java:96)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:512)
	... 31 more

And I don’t realy understant why.

Can someone give me some help ?

Thanks for all your great work.

Hi,

Are you using an RC version or the release version? One bug like that was recently fixed. Also you could use container.refresh() instead of looping all items. That should do pretty much the same thing.

cheers,
matti

I am using the 2.0.0 release.

I tried to use refresh on the container, but I failed in an other way (infinite call to something related to the fact that my entity have a @PostLoad anotation).

Because I may not be on the same timezone I will not be able to read anything before tomorrow.

thanks.

Nevermind, I manage to solve my problem.

In fact my entity have a
@OneToMany
relation, and also, a
@PostLoad
function that try to find the last item of the
OneToMany
relation.

When I was using the
container.refresh()
method, it failed with
StackOverflowError
, that’s why I tryied to solve my problem with the loop on the items in the container.

But I manage to solve my problem, by adding a
fetch = FetchType.EAGER
on my
@OneToMany
relation, and now, everything works !!!

Thanks !