public static Entity valueOf(VersionedEntity entity) {
if(entity instanceof Synonym) {
return TERM_SYNONYM;
}
if(entity instanceof Relationship) {
return TERM_RELATIONSHIP;
}
if(entity instanceof Term) {
return TERM;
}
if(entity instanceof RelationshipType) {
return RELATIONSHIP_TYPE;
}
if(entity instanceof Ontology) {
return ONTOLOGY;
}
throw new IllegalArgumentException("Invalid entity: " + entity.getClass().getName());
}
java类javax.persistence.Entity的实例源码
CuratorApprovalWeight.java 文件源码
项目:ontobrowser
阅读 25
收藏 0
点赞 0
评论 0
AuditableListener.java 文件源码
项目:metaworks_framework
阅读 33
收藏 0
点赞 0
评论 0
@PrePersist
public void setAuditCreatedBy(Object entity) throws Exception {
if (entity.getClass().isAnnotationPresent(Entity.class)) {
Field field = getSingleField(entity.getClass(), "auditable");
field.setAccessible(true);
if (field.isAnnotationPresent(Embedded.class)) {
Object auditable = field.get(entity);
if (auditable == null) {
field.set(entity, new Auditable());
auditable = field.get(entity);
}
Field temporalField = auditable.getClass().getDeclaredField("dateCreated");
Field agentField = auditable.getClass().getDeclaredField("createdBy");
setAuditValueTemporal(temporalField, auditable);
setAuditValueAgent(agentField, auditable);
}
}
}
AuditableListener.java 文件源码
项目:blcdemo
阅读 28
收藏 0
点赞 0
评论 0
@PreUpdate
public void setAuditUpdatedBy(Object entity) throws Exception {
if (entity.getClass().isAnnotationPresent(Entity.class)) {
Field field = getSingleField(entity.getClass(), "auditable");
field.setAccessible(true);
if (field.isAnnotationPresent(Embedded.class)) {
Object auditable = field.get(entity);
if (auditable == null) {
field.set(entity, new Auditable());
auditable = field.get(entity);
}
Field temporalField = auditable.getClass().getDeclaredField("dateUpdated");
Field agentField = auditable.getClass().getDeclaredField("updatedBy");
setAuditValueTemporal(temporalField, auditable);
setAuditValueAgent(agentField, auditable);
}
}
}
HydratedSetup.java 文件源码
项目:metaworks_framework
阅读 28
收藏 0
点赞 0
评论 0
private static String getInheritanceHierarchyRoot(Class<?> myEntityClass) {
String myEntityName = myEntityClass.getName();
if (inheritanceHierarchyRoots.containsKey(myEntityName)) {
return inheritanceHierarchyRoots.get(myEntityName);
}
Class<?> currentClass = myEntityClass;
boolean eof = false;
while (!eof) {
Class<?> superclass = currentClass.getSuperclass();
if (superclass.equals(Object.class) || !superclass.isAnnotationPresent(Entity.class)) {
eof = true;
} else {
currentClass = superclass;
}
}
if (!currentClass.isAnnotationPresent(Cache.class)) {
currentClass = myEntityClass;
}
inheritanceHierarchyRoots.put(myEntityName, currentClass.getName());
return inheritanceHierarchyRoots.get(myEntityName);
}
StoreManager.java 文件源码
项目:xap-openspaces
阅读 33
收藏 0
点赞 0
评论 0
/**
* Validates the provided class' annotations.
* Currently the only validation performed is for @Id & @SpaceId annotations
* that must be declared on the same getter.
*/
private void validateClassAnnotations(Class<?> type) {
// Validation is only relevant for Entities
if (type.getAnnotation(Entity.class) == null)
return;
for (Method getter : type.getMethods()) {
if (!getter.getName().startsWith("get"))
continue;
SpaceId spaceId = getter.getAnnotation(SpaceId.class);
boolean hasJpaId = getter.getAnnotation(Id.class) != null || getter.getAnnotation(EmbeddedId.class) != null;
if (spaceId != null || hasJpaId) {
if (!hasJpaId || spaceId == null)
throw new IllegalArgumentException("SpaceId and Id annotations must both be declared on the same property in JPA entities in type: " + type.getName());
if (spaceId.autoGenerate()) {
GeneratedValue generatedValue = getter.getAnnotation(GeneratedValue.class);
if (generatedValue == null || generatedValue.strategy() != GenerationType.IDENTITY)
throw new IllegalArgumentException(
"SpaceId with autoGenerate=true annotated property should also have a JPA GeneratedValue annotation with strategy = GenerationType.IDENTITY.");
}
break;
}
}
}
TerminalServiceImpl.java 文件源码
项目:iris
阅读 22
收藏 0
点赞 0
评论 0
BigInteger determineUniqueId() {
String entityName = Terminal.class.getAnnotation(Entity.class).name();
BigInteger nextUniqueId = uniqueIdSequenceService.getNextId(entityName);
boolean isUniqueIdAlreadyAssigned = terminalRepository.findByUniqueId(nextUniqueId) != null;
while (isUniqueIdAlreadyAssigned) {
// In this loop we increment the ID by ourselves to avoid write-accesses to the DB for performance.
LOG.warn("Terminal uniqueId {} already assigned - trying next uniqueId", nextUniqueId);
nextUniqueId = nextUniqueId.add(BigInteger.ONE);
if (terminalRepository.findByUniqueId(nextUniqueId) == null) {
isUniqueIdAlreadyAssigned = false;
uniqueIdSequenceService.setNextId(entityName, nextUniqueId);
}
}
return nextUniqueId;
}
AdminAuditableListener.java 文件源码
项目:SparkCommerce
阅读 27
收藏 0
点赞 0
评论 0
@PrePersist
public void setAuditCreatedBy(Object entity) throws Exception {
if (entity.getClass().isAnnotationPresent(Entity.class)) {
Field field = getSingleField(entity.getClass(), "auditable");
field.setAccessible(true);
if (field.isAnnotationPresent(Embedded.class)) {
Object auditable = field.get(entity);
if (auditable == null) {
field.set(entity, new AdminAuditable());
auditable = field.get(entity);
}
Field temporalCreatedField = auditable.getClass().getDeclaredField("dateCreated");
Field temporalUpdatedField = auditable.getClass().getDeclaredField("dateUpdated");
Field agentField = auditable.getClass().getDeclaredField("createdBy");
setAuditValueTemporal(temporalCreatedField, auditable);
setAuditValueTemporal(temporalUpdatedField, auditable);
setAuditValueAgent(agentField, auditable);
}
}
}
AdminAuditableListener.java 文件源码
项目:SparkCommerce
阅读 22
收藏 0
点赞 0
评论 0
@PreUpdate
public void setAuditUpdatedBy(Object entity) throws Exception {
if (entity.getClass().isAnnotationPresent(Entity.class)) {
Field field = getSingleField(entity.getClass(), "auditable");
field.setAccessible(true);
if (field.isAnnotationPresent(Embedded.class)) {
Object auditable = field.get(entity);
if (auditable == null) {
field.set(entity, new AdminAuditable());
auditable = field.get(entity);
}
Field temporalField = auditable.getClass().getDeclaredField("dateUpdated");
Field agentField = auditable.getClass().getDeclaredField("updatedBy");
setAuditValueTemporal(temporalField, auditable);
setAuditValueAgent(agentField, auditable);
}
}
}
AuditableListener.java 文件源码
项目:SparkCommerce
阅读 28
收藏 0
点赞 0
评论 0
@PrePersist
public void setAuditCreatedBy(Object entity) throws Exception {
if (entity.getClass().isAnnotationPresent(Entity.class)) {
Field field = getSingleField(entity.getClass(), "auditable");
field.setAccessible(true);
if (field.isAnnotationPresent(Embedded.class)) {
Object auditable = field.get(entity);
if (auditable == null) {
field.set(entity, new Auditable());
auditable = field.get(entity);
}
Field temporalField = auditable.getClass().getDeclaredField("dateCreated");
Field agentField = auditable.getClass().getDeclaredField("createdBy");
setAuditValueTemporal(temporalField, auditable);
setAuditValueAgent(agentField, auditable);
}
}
}
AuditableListener.java 文件源码
项目:SparkCommerce
阅读 32
收藏 0
点赞 0
评论 0
@PreUpdate
public void setAuditUpdatedBy(Object entity) throws Exception {
if (entity.getClass().isAnnotationPresent(Entity.class)) {
Field field = getSingleField(entity.getClass(), "auditable");
field.setAccessible(true);
if (field.isAnnotationPresent(Embedded.class)) {
Object auditable = field.get(entity);
if (auditable == null) {
field.set(entity, new Auditable());
auditable = field.get(entity);
}
Field temporalField = auditable.getClass().getDeclaredField("dateUpdated");
Field agentField = auditable.getClass().getDeclaredField("updatedBy");
setAuditValueTemporal(temporalField, auditable);
setAuditValueAgent(agentField, auditable);
}
}
}