What steps will reproduce the problem?
1. I've created a User object with bidirectional 1:M relationships with
History, Branding and Content objects. The history and branding relationships
are defined in a 'bits' fetch group. The content relationship is defined in a
'content' fetch group:
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
@FetchGroups({@FetchGroup(name="bits",
members={@Persistent(name="userHistory"),@Persistent(name="userBranding")}),
@FetchGroup(name="content", members={@Persistent(name="userContent")})})
public class User implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private String username;
@Persistent
private String email;
@Persistent(mappedBy = "contentUser", defaultFetchGroup = "false")
@Element(dependent = "true")
@Order(extensions = @Extension(vendorName = "datanucleus", key = "list-ordering", value = "contentKey asc"))
private List<Content> userContent;
@Persistent(mappedBy = "historyUser", defaultFetchGroup = "false")
@Element(dependent = "true")
@Order(extensions = @Extension(vendorName = "datanucleus", key = "list-ordering", value = "createdDate asc"))
private List<History> userHistory;
@Persistent(mappedBy = "brandingUser", defaultFetchGroup = "false")
@Element(dependent = "true")
private List<MediaBranding> userBranding;
...
}
2. Store a User object and related History, Branding and Content objects
Perform a JDOQL query on a non-key field of User (email in this case), setting
the 'bits' and 'content' fetch groups:
User result = null;
try {
pm.getFetchPlan().addGroup("bits");
pm.getFetchPlan().addGroup("content");
log.info("Groups in fetch plan: " + pm.getFetchPlan().getGroups());
Query query = pm.newQuery(User.class);
query.setFilter("email == emailParam");
query.declareParameters("java.lang.String emailParam");
List<User> results = (List<User>) query.execute("hello@site.net");
assertEquals(1, results.size());
result = results.get(0);
pm.makeTransient(result, true);
} finally {
pm.close();
}
3. Check that the related History, Branding and Content objects are fetched
along with the User.
What is the expected output? What do you see instead?
I expect the related History, Branding and Content objects to be present when
calling getUserHistory(), getUserBranding() and getUserContent(). Instead I
get NULL when calling these getters.
What version of the product are you using? On what operating system?
datanucleus-appengine 2.1.0-SNAPSHOT (r859)
OS: Linux (Ubuntu 10.04 LTS, kernel 2.6.32-40-server x86_64)
Please provide any additional information below.
I've attached a tarball with the test cases - three fail against 2.1.0-SNAPSHOT:
testAddRetrieveUserByJDOQLQueryFetchGroups
testAddRetrieveUserByJDOQLQuerySingleFetchGroupContent
testAddRetrieveUserByJDOQLQuerySingleFetchGroupBits
Confirmed these tests work against datanucleus-appengine 1.1.5 (alternative pom
supplied in tarball).
Thanks,
Rob
Original issue reported on code.google.com by robert.w...@metacdn.com on 24 Apr 2012 at 4:41
Original issue reported on code.google.com by
robert.w...@metacdn.com
on 24 Apr 2012 at 4:41Attachments: