DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Type: Bug Bug
Status: Closed Closed
Resolution: Cannot Reproduce
Priority: Testcase Required Testcase Required
Assignee: Unassigned
Reporter: Chris Rued
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
DataNucleus Store MongoDB

@PostLoad not being called after a query

Created: 31/May/12 05:48 PM   Updated: 18/Jun/12 10:05 AM   Resolved: 15/Jun/12 08:58 AM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Datastore: MongoDB

 Description  « Hide
I can produce a test case showing this if you like, but don't have time at the moment and just wanted to record what I observed...

If I add a @PostLoad annotation to a method in a JPA Entity like so:

    private void postLoad() {
        System.err.println("POST LOAD CALLED!!!");

The post load is not invoked when I execute a query and iterator over the result list...e.g.:

        // @PostLoad is not called when executing this query or iterating over results
        Query q = entityManager.createQuery("SELECT e FROM ExampleEntity e");
        List<ExampleEntity > resultList = q.getResultList();
        for ( ExampleEntity ee : resultList ) {
            System.err.println("found: " + ee);

It looks like the @PostLoad method is called if I load the entity directly using the EntityManager.find() method:

        // @PostLoad is called as a result of the find() method being called
        ExampleEntity find = entityManager.find(ExampleEntity.class, "8a9981073784a72b013784a72b440000");

Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 31/May/12 07:19 PM
Don't see what this has to do with the MongoDB plugin; store plugins don't handle lifecycle events - that's core or "api.jdo"/"ajp.jpa".
I also cannot reproduce any such issue with JPA and postLoad ... using DN tests or the JPA1 TCK. Obviously I'm using latest code on all plugins. As for anyone else raising an issue, a testcase is prerequisite for anything, unless the raiser is going to debug/fix it themselves.

Chris Rued added a comment - 31/May/12 08:04 PM
Thanks for looking into it. I only filed it under the MongoDB plugin because that is the data store I was using when I observed it.

I'll try it on the latest code. If I am able to reproduce it, I will provide a test case to illustrate how.