ObjectDB ObjectDB

Issue #552: Eager load Map

Type: Bug ReoprtPriority: NormalStatus: FixedReplies: 7
#1

I'm having an issue eager loading a nested map. I've attached @ManyToMany(fetch=FetchType.EAGER) attributes to no avail. If the map is viewed in the debugger or force iterated in the code it loads ok.

The attached code attempts to replicate the scenario. Its not an exact match but is the best I could come up with without replicating the whole system.

The test creates an object, persists it to a db and re-loads it. The EntityManager is closed before accesing any fields. Finally the nested map is accessed and printed to screen.

On the first run of the test everything works as expected - the map is loaded and its contents are printed.

On the second run (without deleting or clearing the database) the map is empty. Looking at the database through objectdb explorer shows the map contents have saved ok.

If you could help me understand what is happening it'd be much appreciated!

edit
delete
#2

There was a bug in eager fetch of collections and maps of simple values.

Build 2.3.2_04 should fix this problem.

ObjectDB Support
edit
delete
#3

Thanks - that fixed the test but unfortunately I still had the problem in the real application. It seems my example wasn't fully representative so apologies for that.

I've attached another go. The main difference here is that I'm using "find" to retrieve the objects from the database.

If you run the test as-is the objects are retrieved and the nested map is empty so nothing is printed to the console. If you uncomment the 2 lines after the "find" and re-run the test, the map is iterated and thus force loaded so the print works as expected.

edit
delete
#4

Strange. I get the following output when the lines are in comments:

k3 - v3
k1 - v1
k2 - v2

I tried with and without enhancement. Is there a chance that you were using an older build?

ObjectDB Support
edit
delete
#5

That's odd...

I went back to double check and I'm definitely using 2.3.2_04. I had a play with a few options and found that it works if I add runtime enhancement (i.e. javaagent:objectdb.jar) but unenhanced it refuses to work when I use "find" to load the object.

I've been meaning to enhance the application classes for a while so am happy to push forward with that as it seems to work.

edit
delete
#6

Checked again and it works with no enhancement as well in my environment, so for now I am closing this issue.

Thank you for your report.

ObjectDB Support
edit
delete
#7

Sure - thats fine by me.

Just for reference what environment are you running in? (Just in case I can track down the difference).

I'm running on WindowsXP using jdk1.5.0_21, junit-4.7

edit
delete
#8

Windows XP SP 3, jdk1.6.0_13, junit 4.8.1.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.