- Put the datanucleus-googlecollections plugin in the CLASSPATH
- Develop your model using the Multiset java type.
- Make sure that your Multiset field uses a join-table when persisting to RDBMS, and that the join-table doesn't have a primary-key defined
So if we have
@PersistenceCapable
public class Sample
{
@Join(extensions=
@Extension(vendorName="datanucleus",
key="primary-key", value="false"))
Multisetelements = null;
...
}
this will create an RDBMS join table as
CREATE TABLE SAMPLE_ELEMENTS
(
ID_OID BIGINT NOT NULL,
ID_EID BIGINT NOT NULL
);
i.e no primary key, and so we can have duplicates of the same element in the Multiset.
Thereafter the persistence just performs as normal (for JDO or JPA).
No comments:
Post a Comment