openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig Russell (JIRA)" <>
Subject [jira] Commented: (OPENJPA-370) LoadFetchGroup annotation was not recognized during the fetch1
Date Sat, 03 Nov 2007 01:15:51 GMT


Craig Russell commented on OPENJPA-370:

The test case doesn't have an example of where load fetch group is used. The only tests are
for regular fetch groups. Some specific comments:

1. The test case should use spaces not tabs for delimiters.

2. The tests should use commit not rollback to detach the instances.

3. The tests testFieldsInFetchGroupAndLoadFetchGroupAreLoaded and testFieldsInFetchGroupAndLoadFetchGroupAreLoadedUsingFind

don't test load fetch groups. I'd suggest renaming them and changing their expected results
as follows:

	 * Verifies that when a field with a LoadFetchGroup L is fetched, the fields
	 * included in L are not fetched either.
	public void testFieldsInFetchGroupAndNotLoadFetchGroupAreLoaded() {
		OpenJPAEntityManager em = emf.createEntityManager();
		List<PObject> pcs = findByQuery(em, "SELECT p FROM PObject p", "f3");
		for (PObject pc:pcs) 
			assertLoaded(em, pc, "f3");
	public void testFieldsInFetchGroupAndNotLoadFetchGroupAreLoadedUsingFind() {
		OpenJPAEntityManager em = emf.createEntityManager();
		PObject pc = findById(em, OID, "f3");
		assertLoaded(em, pc, "f3");
To test load fetch group you need to add internal methods that load field f3 after querying
or finding it and then commit the transaction. Something like findByIdAndAccessField (OpenJPAEntityManager
em, String field, Object oid, String... fetchGroups). After finding the object, it would access
the named field and then commit. Similar functionality is needed for findByQueryAndAccessField.

To do this, I would refactor isLoaded into isLoaded and loadField. The loadField can be used
by the findByIdAndAccessField and findByQueryAndAccessField methods to access a field.

> LoadFetchGroup annotation was not recognized during the fetch1
> --------------------------------------------------------------
>                 Key: OPENJPA-370
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 1.0.1, 1.0.2, 1.1.0
>            Reporter: Teresa Kan
>            Assignee: Teresa Kan
>             Fix For: 1.0.2, 1.1.0
>         Attachments: OPENJPA_370_2.patch,,
> Employee class has a LoadFetchGroup annotation defined on the Rating field, when getRating
was called, the address should be returned also. However, openjpa did not handle the LoadFetchGroup
correctly, therefore, address was not eargly fetched.
> public class FGEmployee{
>     @Id
>     private int id;
>     @OneToOne(fetch=FetchType.LAZY) 
>     private FGAddress address;
>     @Basic(fetch=FetchType.LAZY)
>     @LoadFetchGroup("AddressFetchGroup")
>     private String rating;
>     @ManyToOne(fetch=FetchType.LAZY)
>     private FGManager manager;
> ..
> }

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message