本文整理匯總了Java中javax.jdo.annotations.IdentityType類的典型用法代碼示例。如果您正苦於以下問題:Java IdentityType類的具體用法?Java IdentityType怎麽用?Java IdentityType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IdentityType類屬於javax.jdo.annotations包,在下文中一共展示了IdentityType類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addEntityMetadata
import javax.jdo.annotations.IdentityType; //導入依賴的package包/類
@Override
public void addEntityMetadata(JDOMetadata jdoMetadata, EntityDto entity, Class<?> definition, SchemaHolder schemaHolder) {
String className = (entity.isDDE()) ? entity.getClassName() : ClassName.getEntityClassName(entity.getClassName());
String packageName = ClassName.getPackage(className);
String tableName = ClassTableName.getTableName(entity.getClassName(), entity.getModule(), entity.getNamespace(), entity.getTableName(), null);
PackageMetadata pmd = getPackageMetadata(jdoMetadata, packageName);
ClassMetadata cmd = getClassMetadata(pmd, ClassName.getSimpleName(ClassName.getEntityClassName(entity.getClassName())));
cmd.setTable(tableName);
cmd.setDetachable(true);
cmd.setIdentityType(IdentityType.APPLICATION);
cmd.setPersistenceModifier(ClassPersistenceModifier.PERSISTENCE_CAPABLE);
addInheritanceMetadata(cmd, definition);
if (!entity.isSubClassOfMdsEntity() && !entity.isSubClassOfMdsVersionedEntity()) {
addIdField(cmd, entity, schemaHolder, definition);
//we add versioning metadata only for Standard class.
addVersioningMetadata(cmd, definition);
}
addMetadataForFields(cmd, null, entity, EntityType.STANDARD, definition, schemaHolder);
}
示例2: addHelperClassMetadata
import javax.jdo.annotations.IdentityType; //導入依賴的package包/類
@Override
public void addHelperClassMetadata(JDOMetadata jdoMetadata, ClassData classData,
EntityDto entity, EntityType entityType, Class<?> definition,
SchemaHolder schemaHolder) {
String packageName = ClassName.getPackage(classData.getClassName());
String simpleName = ClassName.getSimpleName(classData.getClassName());
String tableName = ClassTableName.getTableName(classData.getClassName(), classData.getModule(), classData.getNamespace(),
entity == null ? "" : entity.getTableName(), entityType);
PackageMetadata pmd = getPackageMetadata(jdoMetadata, packageName);
ClassMetadata cmd = getClassMetadata(pmd, simpleName);
cmd.setTable(tableName);
cmd.setDetachable(true);
cmd.setIdentityType(IdentityType.APPLICATION);
cmd.setPersistenceModifier(ClassPersistenceModifier.PERSISTENCE_CAPABLE);
InheritanceMetadata imd = cmd.newInheritanceMetadata();
imd.setCustomStrategy("complete-table");
addIdField(cmd, classData.getClassName(), definition);
if (entity != null) {
addMetadataForFields(cmd, classData, entity, entityType, definition, schemaHolder);
}
}
示例3: isClassPersistable
import javax.jdo.annotations.IdentityType; //導入依賴的package包/類
@Override
protected AnnotationObject isClassPersistable(Class cls) {
AnnotationObject annotationObject = super.isClassPersistable(cls);
// if super does not recognize this object as PC, then try looking for the Entity annotation
// only when FileMetadata has been already loaded
if (annotationObject == null && ReflectionsUtil.hasAnnotation(cls, Entity.class) &&
!ArrayUtils.isEmpty(mgr.getFileMetaData())) {
// default params
HashMap<String, Object> annotationParams = new HashMap<>();
annotationParams.put("identityType", IdentityType.DATASTORE);
Class superClass = cls.getSuperclass();
while (superClass != null) {
if (superClass == MdsEntity.class || superClass == MdsVersionedEntity.class) {
annotationParams.put("identityType", IdentityType.APPLICATION);
}
superClass = superClass.getSuperclass();
}
annotationParams.put("detachable", Constants.Util.TRUE);
// we fake a persistence capable annotation
annotationObject = new AnnotationObject(PersistenceCapable.class.getName(), annotationParams);
}
return annotationObject;
}
示例4: shouldRecognizeEntityAnnotation
import javax.jdo.annotations.IdentityType; //導入依賴的package包/類
@Test
public void shouldRecognizeEntityAnnotation() {
when(metaDataManager.getFileMetaData()).thenReturn(new FileMetaData[1]);
AnnotationObject result = mdsJdoAnnotationReader.isClassPersistable(Record.class);
assertEquals(PersistenceCapable.class.getName(), result.getName());
assertNotNull(result.getNameValueMap());
assertEquals(IdentityType.DATASTORE, result.getNameValueMap().get("identityType"));
assertEquals("true", result.getNameValueMap().get("detachable"));
}
示例5: shouldPrioritizePersistenceCapableAnnotationValuesOverEntityDefaults
import javax.jdo.annotations.IdentityType; //導入依賴的package包/類
@Test
public void shouldPrioritizePersistenceCapableAnnotationValuesOverEntityDefaults() {
AnnotationObject result = mdsJdoAnnotationReader.isClassPersistable(PcAndEntity.class);
assertEquals(PersistenceCapable.class.getName(), result.getName());
assertNotNull(result.getNameValueMap());
assertEquals(IdentityType.APPLICATION, result.getNameValueMap().get("identityType"));
assertEquals("false", result.getNameValueMap().get("detachable"));
assertEquals("testCatalog", result.getNameValueMap().get("catalog"));
}
示例6: verifyCommonClassMetadata
import javax.jdo.annotations.IdentityType; //導入依賴的package包/類
private void verifyCommonClassMetadata(IdGeneratorStrategy expextedStrategy) {
verify(classMetadata).setDetachable(true);
verify(classMetadata).setIdentityType(IdentityType.APPLICATION);
verify(classMetadata).setPersistenceModifier(ClassPersistenceModifier.PERSISTENCE_CAPABLE);
verify(idMetadata).setPrimaryKey(true);
verify(idMetadata).setValueStrategy(expextedStrategy);
verify(inheritanceMetadata).setCustomStrategy("complete-table");
}
示例7: populate
import javax.jdo.annotations.IdentityType; //導入依賴的package包/類
public JDOMetadata populate(JDOMetadata md, String fullyQualifiedClassName, String fieldName) {
PackageMetadata pmd = md.newPackageMetadata(fullyQualifiedClassName.substring(0, fullyQualifiedClassName.lastIndexOf(".")));
ClassMetadata cmd = pmd.newClassMetadata(fullyQualifiedClassName.substring(fullyQualifiedClassName.lastIndexOf(".") + 1));
cmd.setTable(new ClassName(fullyQualifiedClassName).getSimpleName().toLowerCase()).setDetachable(true);
cmd.setPersistenceModifier(ClassPersistenceModifier.PERSISTENCE_CAPABLE);
cmd.setIdentityType(IdentityType.APPLICATION);
cmd.newDatastoreIdentityMetadata().setStrategy(IdGeneratorStrategy.INCREMENT);
cmd.newInheritanceMetadata().setStrategy(InheritanceStrategy.NEW_TABLE);
FieldMetadata fmd = cmd.newFieldMetadata(fieldName);
fmd.setNullValue(NullValue.DEFAULT).setColumn(fieldName);
return md;
}
示例8: populate
import javax.jdo.annotations.IdentityType; //導入依賴的package包/類
public JDOMetadata populate(JDOMetadata md, String fullyQualifiedClassName, String fieldName) {
String packageName = fullyQualifiedClassName.substring(0, fullyQualifiedClassName.lastIndexOf("."));
PackageMetadata pmd = md.newPackageMetadata(packageName);
String className = fullyQualifiedClassName.substring(fullyQualifiedClassName.lastIndexOf(".") + 1);
ClassMetadata cmd = pmd.newClassMetadata(className);
cmd.setTable(className.toUpperCase()).setDetachable(true);
cmd.setIdentityType(IdentityType.DATASTORE);
cmd.setPersistenceModifier(ClassPersistenceModifier.PERSISTENCE_CAPABLE);
FieldMetadata fmd = cmd.newFieldMetadata(fieldName);
fmd.setNullValue(NullValue.DEFAULT).setColumn(fieldName);
return md;
}
示例9: searchAndTest
import javax.jdo.annotations.IdentityType; //導入依賴的package包/類
@SuppressWarnings("rawtypes")
@Test
public void searchAndTest() {
Reflections reflections = new Reflections("org.estatio.dom");
Set<Class<? extends UdoDomainObject>> subtypes =
reflections.getSubTypesOf(UdoDomainObject.class);
for (Class<? extends UdoDomainObject> subtype : subtypes) {
if (subtype.isAnonymousClass() || subtype.isLocalClass() || subtype.isMemberClass() || subtype.getName().endsWith("ForTesting")) {
// skip (probably a testing class)
continue;
}
if (UdoDomainObject.class == subtype || UdoDomainObject2.class == subtype) {
// skip
continue;
}
System.out.println(">>> " + subtype.getName());
// must have a @PersistenceCapable(identityType=...) annotation
final PersistenceCapable persistenceCapable = subtype.getAnnotation(PersistenceCapable.class);
Assertions.assertThat(persistenceCapable).isNotNull();
IdentityType identityType = persistenceCapable.identityType();
Assertions.assertThat(identityType).isNotNull();
if (identityType == IdentityType.DATASTORE) {
// NOT mandatory to have a @DatastoreIdentity, but if does, then @DatastoreIdentity(..., column="id")
final DatastoreIdentity datastoreIdentity = subtype.getAnnotation(DatastoreIdentity.class);
if (datastoreIdentity != null) {
Assertions.assertThat(datastoreIdentity.column()).isEqualTo("id");
}
}
Inheritance inheritance = subtype.getAnnotation(Inheritance.class);
if (inheritance != null && inheritance.strategy() == InheritanceStrategy.SUPERCLASS_TABLE) {
// must NOT have a @Discriminator(..., column="discriminator")
final Annotation[] declaredAnnotations = subtype.getDeclaredAnnotations();
for (Annotation declaredAnnotation : declaredAnnotations) {
if (declaredAnnotation.annotationType() == Discriminator.class) {
Assert.fail("Class " + subtype.getName() + " inherits from " + subtype.getSuperclass().getName()
+ "and has (incorrectly) been annotated with @Discriminator");
}
}
// check if supertype has discriminator
// must have a @Discriminator(..., column="discriminator") on one of its supertypes
final Discriminator superDiscriminator = subtype.getSuperclass().getAnnotation(Discriminator.class);
Assertions.assertThat(superDiscriminator).isNotNull();
Assertions.assertThat(superDiscriminator.column()).isEqualTo("discriminator");
}
if (subtype.getSuperclass().equals(UdoDomainObject.class)) {
// must have a @Version(..., column="version")
final Version version = getAnnotationOfTypeOfItsSupertypes(subtype, Version.class);
Assertions.assertThat(version).isNotNull();
Assertions.assertThat(version.column()).isEqualTo("version");
}
}
}