Search in sources :

Example 41 with ClassMetaData

use of org.datanucleus.metadata.ClassMetaData in project tests by datanucleus.

the class AnnotationTest method testPersistenceAware.

/**
 * Test for use of @PersistenceAware
 */
public void testPersistenceAware() {
    ClassMetaData cmd1 = (ClassMetaData) metaDataMgr.getMetaDataForClass(AccessPublicFields.class.getName(), clr);
    String prefix = cmd1.getFullClassName() + " : ";
    assertNotNull(prefix + "has no MetaData!", cmd1);
    assertTrue(prefix + "is not PersistenceAware yet should be", cmd1.getPersistenceModifier() == ClassPersistenceModifier.PERSISTENCE_AWARE);
}
Also used : ClassMetaData(org.datanucleus.metadata.ClassMetaData)

Example 42 with ClassMetaData

use of org.datanucleus.metadata.ClassMetaData in project tests by datanucleus.

the class AnnotationTest method testPersistentProperties.

/**
 * Test of specifying annotations on getters.
 */
public void testPersistentProperties() {
    ClassMetaData cmd1 = (ClassMetaData) metaDataMgr.getMetaDataForClass(MyPropertyBean.class.getName(), clr);
    assertEquals(1, cmd1.getNoOfPrimaryKeyMembers());
}
Also used : ClassMetaData(org.datanucleus.metadata.ClassMetaData)

Example 43 with ClassMetaData

use of org.datanucleus.metadata.ClassMetaData in project tests by datanucleus.

the class AnnotationTest method testNonPersistent.

/**
 * Test of @NotPersistent on a field.
 */
public void testNonPersistent() {
    ClassMetaData cmd = (ClassMetaData) metaDataMgr.getMetaDataForClass(Person.class.getName(), clr);
    String prefix = cmd.getFullClassName() + " : ";
    AbstractMemberMetaData fmd = cmd.getMetaDataForMember("mood");
    assertEquals(prefix + "field should be non-persistent", FieldPersistenceModifier.NONE, fmd.getPersistenceModifier());
}
Also used : AbstractMemberMetaData(org.datanucleus.metadata.AbstractMemberMetaData) ClassMetaData(org.datanucleus.metadata.ClassMetaData)

Example 44 with ClassMetaData

use of org.datanucleus.metadata.ClassMetaData in project tests by datanucleus.

the class AnnotationTest method testVersion.

/**
 * Test for use of version specification in annotations
 */
public void testVersion() {
    ClassMetaData cmd1 = (ClassMetaData) metaDataMgr.getMetaDataForClass(Trade1.class.getName(), clr);
    String prefix = cmd1.getFullClassName() + " : ";
    VersionMetaData vermd = cmd1.getVersionMetaData();
    assertNotNull(prefix + "has no VersionMetaData", vermd);
    assertEquals(prefix + "has incorrect version strategy", "version-number", vermd.getVersionStrategy().toString());
    assertNotNull(prefix + "has incorrect version column info", vermd.getColumnMetaData());
    assertEquals(prefix + "has incorrect version column name", "TRADE_VERSION", vermd.getColumnMetaData().getName());
}
Also used : VersionMetaData(org.datanucleus.metadata.VersionMetaData) ClassMetaData(org.datanucleus.metadata.ClassMetaData)

Example 45 with ClassMetaData

use of org.datanucleus.metadata.ClassMetaData in project tests by datanucleus.

the class AnnotationTest method testMapKeyInValue.

/**
 * Test for use of map with using @Key, @Value.
 */
public void testMapKeyInValue() {
    ClassMetaData cmd1 = (ClassMetaData) metaDataMgr.getMetaDataForClass(Person.class.getName(), clr);
    String prefix = cmd1.getFullClassName() + " : ";
    AbstractMemberMetaData fmd = cmd1.getMetaDataForMember("phoneNumbers");
    assertNotNull(prefix + "doesnt have required field", fmd);
    MapMetaData mapmd = fmd.getMap();
    assertNotNull(prefix + "MapMetaData is null!", mapmd);
    assertEquals(prefix + "MapMetaData keyType is incorrect", String.class.getName(), mapmd.getKeyType());
    assertEquals(prefix + "MapMetaData valueType is incorrect", PhoneNumber.class.getName(), mapmd.getValueType());
    JoinMetaData joinmd = fmd.getJoinMetaData();
    assertNull(prefix + "field \"phoneNumbers\" has join information!", joinmd);
    KeyMetaData keymd = fmd.getKeyMetaData();
    assertEquals(prefix + "field \"phoneNumbers\" has incorrect key mapped-by", "name", keymd.getMappedBy());
}
Also used : KeyMetaData(org.datanucleus.metadata.KeyMetaData) PrimaryKeyMetaData(org.datanucleus.metadata.PrimaryKeyMetaData) PhoneNumber(org.datanucleus.samples.annotations.models.company.PhoneNumber) JoinMetaData(org.datanucleus.metadata.JoinMetaData) MapMetaData(org.datanucleus.metadata.MapMetaData) AbstractMemberMetaData(org.datanucleus.metadata.AbstractMemberMetaData) ClassMetaData(org.datanucleus.metadata.ClassMetaData)

Aggregations

ClassMetaData (org.datanucleus.metadata.ClassMetaData)109 AbstractMemberMetaData (org.datanucleus.metadata.AbstractMemberMetaData)55 MetaDataManager (org.datanucleus.metadata.MetaDataManager)55 ClassLoaderResolver (org.datanucleus.ClassLoaderResolver)53 NucleusContext (org.datanucleus.NucleusContext)52 PersistenceNucleusContextImpl (org.datanucleus.PersistenceNucleusContextImpl)51 JPAMetaDataManager (org.datanucleus.api.jpa.metadata.JPAMetaDataManager)51 PersistenceUnitMetaData (org.datanucleus.metadata.PersistenceUnitMetaData)38 AbstractClassMetaData (org.datanucleus.metadata.AbstractClassMetaData)18 ClassLoaderResolverImpl (org.datanucleus.ClassLoaderResolverImpl)14 ColumnMetaData (org.datanucleus.metadata.ColumnMetaData)14 ElementMetaData (org.datanucleus.metadata.ElementMetaData)14 JoinMetaData (org.datanucleus.metadata.JoinMetaData)14 PackageMetaData (org.datanucleus.metadata.PackageMetaData)14 Label (org.datanucleus.enhancer.asm.Label)6 FileMetaData (org.datanucleus.metadata.FileMetaData)6 InterfaceMetaData (org.datanucleus.metadata.InterfaceMetaData)6 PropertyMetaData (org.datanucleus.metadata.PropertyMetaData)6 KeyMetaData (org.datanucleus.metadata.KeyMetaData)5 MapMetaData (org.datanucleus.metadata.MapMetaData)5