use of javax.jdo.metadata.VersionMetadata in project tests by datanucleus.
the class DynamicEnhanceSchemaToolTest method createMetadata.
private static void createMetadata(JDOMetadata filemd) {
PackageMetadata pmd = filemd.newPackageMetadata("test");
ClassMetadata cmd = pmd.newClassMetadata("Client");
cmd.setTable("CLIENT").setDetachable(true).setIdentityType(javax.jdo.annotations.IdentityType.DATASTORE);
cmd.setPersistenceModifier(javax.jdo.metadata.ClassPersistenceModifier.PERSISTENCE_CAPABLE);
FieldMetadata fmd = cmd.newFieldMetadata("name");
fmd.setNullValue(javax.jdo.annotations.NullValue.DEFAULT).setColumn("name").setIndexed(true).setUnique(true);
InheritanceMetadata inhmd = cmd.newInheritanceMetadata();
inhmd.setStrategy(javax.jdo.annotations.InheritanceStrategy.NEW_TABLE);
DiscriminatorMetadata dmd = inhmd.newDiscriminatorMetadata();
dmd.setColumn("disc").setValue("Client").setStrategy(javax.jdo.annotations.DiscriminatorStrategy.VALUE_MAP).setIndexed(Indexed.TRUE);
VersionMetadata vermd = cmd.newVersionMetadata();
vermd.setStrategy(javax.jdo.annotations.VersionStrategy.VERSION_NUMBER).setColumn("version").setIndexed(Indexed.TRUE);
}
use of javax.jdo.metadata.VersionMetadata in project motech by motech.
the class EntityMetadataBuilderImpl method addVersioningMetadata.
private void addVersioningMetadata(ClassMetadata cmd, Class<?> definition) {
Class<Version> ann = ReflectionsUtil.getAnnotationClass(definition, Version.class);
Version versionAnnotation = AnnotationUtils.findAnnotation(definition, ann);
if (versionAnnotation != null) {
VersionMetadata vmd = cmd.newVersionMetadata();
vmd.setColumn(versionAnnotation.column());
vmd.setStrategy(versionAnnotation.strategy());
if (versionAnnotation.extensions().length == 0 || !"field-name".equals(versionAnnotation.extensions()[0].key())) {
throw new MdsException(String.format("Cannot create metadata fo %s. Extension not found in @Version annotation.", cmd.getName()));
}
Extension extension = versionAnnotation.extensions()[0];
vmd.newExtensionMetadata(DATANUCLEUS, "field-name", extension.value());
}
}
Aggregations