422 words

Issue #81 - Eager load Map

BugVersion: Priority: NormalStatus: FixedReplies: 7
#1
2011-11-03 16:41

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!

felixobjectdb
felixobjectdb's picture
Joined on 2011-02-10
User Post #58
#2
2011-11-03 21:16

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #690
#3
2011-11-04 10:26

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.

felixobjectdb
felixobjectdb's picture
Joined on 2011-02-10
User Post #59
#4
2011-11-04 10:55

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #692
#5
2011-11-04 11:18

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.

felixobjectdb
felixobjectdb's picture
Joined on 2011-02-10
User Post #60
#6
2011-11-04 11:27

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #693
#7
2011-11-04 11:32

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

felixobjectdb
felixobjectdb's picture
Joined on 2011-02-10
User Post #61
#8
2011-11-04 11:47

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

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #694

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel