Examples of EntityType


Examples of org.beangle.model.entity.types.EntityType

    return (T) populate(type.newInstance(), type.getEntityName(), name);
  }

  @SuppressWarnings("unchecked")
  public static <T> T populate(Class<T> clazz) {
    EntityType type = null;
    if (clazz.isInterface()) {
      type = Model.getEntityType(clazz.getName());
    } else {
      type = Model.getEntityType(clazz);
    }
    String entityName = type.getEntityName();
    return (T) populate(type.newInstance(), entityName, EntityUtils.getCommandName(entityName));
  }
View Full Code Here

Examples of org.beangle.model.entity.types.EntityType

    String entityName = type.getEntityName();
    return (T) populate(type.newInstance(), entityName, EntityUtils.getCommandName(entityName));
  }

  public static Object populate(String entityName) {
    EntityType type = Model.getEntityType(entityName);
    return populate(type.newInstance(), type.getEntityName(), EntityUtils.getCommandName(entityName));
  }
View Full Code Here

Examples of org.beangle.model.entity.types.EntityType

    EntityType type = Model.getEntityType(entityName);
    return populate(type.newInstance(), type.getEntityName(), EntityUtils.getCommandName(entityName));
  }

  public static Object populate(String entityName, String name) {
    EntityType type = Model.getEntityType(entityName);
    return populate(type.newInstance(), type.getEntityName(), name);
  }
View Full Code Here

Examples of org.beangle.model.entity.types.EntityType

   */
  public static List<Condition> extractConditions(Class<?> clazz, String prefix, String exclusiveAttrNames) {
    Object entity = null;
    try {
      if (clazz.isInterface()) {
        EntityType entityType = Model.getEntityType(clazz.getName());
        clazz = entityType.getEntityClass();
      }
      entity = clazz.newInstance();
    } catch (Exception e) {
      throw new RuntimeException("[RequestUtil.extractConditions]: error in in initialize " + clazz);
    }
View Full Code Here

Examples of org.beangle.model.entity.types.EntityType

  public static String getEntityName(Object obj) {
    return context.getEntityName(obj);
  }

  public static EntityType getEntityType(Class<?> clazz) {
    EntityType type = context.getEntityType(clazz);
    if (null == type) {
      type = new EntityType(clazz);
    }
    return type;
  }
View Full Code Here

Examples of org.beangle.model.entity.types.EntityType

      return populate(type.newInstance(), type.getName(), params);
    }
  }

  public Object populate(Class<?> entityClass, Map<String, Object> params) {
    EntityType entityType = Model.getEntityType(entityClass);
    return populate(entityType.newInstance(), entityType.getEntityName(), params);
  }
View Full Code Here

Examples of org.beangle.model.entity.types.EntityType

  private void loggerTypeInfo() {
    List<String> names = CollectUtils.newArrayList(entityTypes.keySet());
    Collections.sort(names);
    for (final String entityName : names) {
      EntityType entityType = (EntityType) entityTypes.get(entityName);
      logger.debug("entity:{}-->{}", entityType.getEntityName(), entityType.getEntityClass().getName());
      logger.debug("propertyType size:{}", Integer.valueOf(entityType.getPropertyTypes().size()));
    }
    names.clear();
    names.addAll(collectionTypes.keySet());
    Collections.sort(names);
    for (final String collectionName : names) {
View Full Code Here

Examples of org.beangle.model.entity.types.EntityType

      return type;
    }
  }

  public String getEntityName(Object obj) {
    EntityType type = getEntityType(obj.getClass());
    if (null != type) {
      return type.getEntityName();
    } else {
      return null;
    }
  }
View Full Code Here

Examples of org.beangle.model.entity.types.EntityType

   *
   * @param entityName
   * @return
   */
  private EntityType buildEntityType(SessionFactory sessionFactory, String entityName) {
    EntityType entityType = (EntityType) entityTypes.get(entityName);
    if (null == entityType) {
      ClassMetadata cm = sessionFactory.getClassMetadata(entityName);
      if (null == cm) {
        logger.error("Cannot find ClassMetadata for {}", entityName);
        return null;
      }
      entityType = new EntityType();
      entityType.setEntityName(cm.getEntityName());
      entityType.setIdPropertyName(cm.getIdentifierPropertyName());
      entityType.setEntityClass(cm.getMappedClass(EntityMode.POJO));
      entityTypes.put(cm.getEntityName(), entityType);

      Map<String, Type> propertyTypes = entityType.getPropertyTypes();
      String[] ps = cm.getPropertyNames();
      for (int i = 0; i < ps.length; i++) {
        org.hibernate.type.Type type = cm.getPropertyType(ps[i]);
        if (type.isEntityType()) {
          propertyTypes.put(ps[i], buildEntityType(sessionFactory, type.getName()));
View Full Code Here

Examples of org.beangle.model.entity.types.EntityType

    }
  }

  public EntityType getEntityType(Class<?> entityClass) {
    String className = entityClass.getName();
    EntityType type = entityTypes.get(className);
    if (null != type) { return type; }

    type = classEntityTypes.get(className);
    if (null == type) {
      List<EntityType> matched = CollectUtils.newArrayList();
      for (EntityType entityType : entityTypes.values()) {
        if (className.equals(entityType.getEntityName())
            || className.equals(entityType.getEntityClass().getName())) {
          matched.add(entityType);
        }
      }
      if (matched.size() > 1) { throw new RuntimeException("multi-entityName for class:" + className); }
      if (matched.isEmpty()) {
        EntityType tmp = new EntityType(entityClass);
        classEntityTypes.put(className, tmp);
        return tmp;
      } else {
        classEntityTypes.put(className, matched.get(0));
        type = (EntityType) matched.get(0);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.