Issue Details (XML | Word | Printable)

Key: NUCENHANCER-78
Type: Improvement Improvement
Status: Closed Closed
Resolution: Won't Fix
Priority: Major Major
Assignee: Unassigned
Reporter: Mike
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Enhancer (ARCHIVED)

Support embedded collections

Created: 31/Aug/11 11:33 PM   Updated: 03/Oct/11 08:28 AM   Resolved: 05/Sep/11 06:59 AM
Component/s: None
Affects Version/s: 3.0.0.release
Fix Version/s: None

Datastore: Other


 Description  « Hide
This code:

@PersistenceCapable
public class User {
@Embedded
public List<Stock> stocks;
}

will result in the following during enhancement:

Field "sw.entity.User.stocks" is of type "java.util.List" yet has been specified as embedded. DataNucleus doesnt support embedding of this type. Your embedded type must be PersistenceCapable. DataNucleus Enhancer completed with an error. Please review the enhancer log for full details. Some classes may have been enhanced but some caused errors.

A workaround is to change the List type to a concrete PersistenceCapable implementation empty wrapper like this:
@PersistenceCapable
public class EmbeddableArrayList<E> extends ArrayList<E> {}
But this is really ugly.

Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 01/Sep/11 09:33 AM
DataNucleus has supported embedded of collection *elements* since day one - you are not embedded the Collection here, but the elements. In JDO @Embedded is to persist the whole field, and you can only do that with a persistable object, not a Collection/Map/array, as per the docs

SVN code allows something like
@Element(embedded="true")
List<MyElement> myList;


Released code requires
@Element(embeddedMembers={...})
List<MyElement> myList;

Andy Jefferson added a comment - 05/Sep/11 06:59 AM
Use aforementioned syntax