Package org.beangle.model.entity.types

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


        clazz = Class.forName(field.getType());
      } catch (ClassNotFoundException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
      }
      EntityType myType=Model.getEntityType(clazz);
      OqlBuilder<T> builder=OqlBuilder.from(myType.getEntityName(), "restrictField");
     
      String[] ids=StringUtils.split(text,",");
      PropertyDescriptor pd=BeanUtils.getPropertyDescriptor(clazz, field.getKeyName());
      Class<?> propertyType=pd.getReadMethod().getReturnType();
      List<Object> realIds=CollectUtils.newArrayList(ids.length);
View Full Code Here


  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

   *
   * @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

    return query;
  }

  @SuppressWarnings("unchecked")
  public static <E> OqlBuilder<E> from(final String entityName, final String alias) {
    EntityType type = Model.getEntityType(entityName);
    OqlBuilder<E> query = new OqlBuilder<E>();
    query.entityClass = (Class<E>) type.getEntityClass();
    query.alias = alias;
    query.select = "select " + alias;
    query.from = concat("from ", entityName, " ", alias);
    return query;
  }
View Full Code Here

    query.from = concat("from ", entityName, " ", alias);
    return query;
  }

  public static <E> OqlBuilder<E> from(final Class<E> entityClass) {
    EntityType type = Model.getEntityType(entityClass.getName());
    if (null == type) {
      type = Model.getEntityType(entityClass);
    }
    return from(entityClass, EntityUtils.getCommandName(type.getEntityName()));
  }
View Full Code Here

      String role) {
    CollectionMetadata cm = sessionFactory.getCollectionMetadata(role);
    // FIXME buildCollectionType
    if (null == cm) { return null; }
    org.hibernate.type.Type type = cm.getElementType();
    EntityType elementType = null;
    if (type.isEntityType()) {
      elementType = (EntityType) entityTypes.get(type.getName());
      if (null == elementType) {
        elementType = buildEntityType(sessionFactory, type.getName());
      }
    } else {
      elementType = new EntityType(type.getReturnedClass());
    }

    CollectionType collectionType = new CollectionType();
    collectionType.setElementType(elementType);
    collectionType.setArray(cm.isArray());
View Full Code Here

    return collectionType;
  }

  private ComponentType buildComponentType(SessionFactory sessionFactory, String entityName,
      String propertyName) {
    EntityType entityType = (EntityType) entityTypes.get(entityName);
    if (null != entityType) {
      Type propertyType = (Type) entityType.getPropertyTypes().get(propertyName);
      if (null != propertyType) { return (ComponentType) propertyType; }
    }

    ClassMetadata cm = sessionFactory.getClassMetadata(entityName);
    org.hibernate.type.ComponentType hcType = (org.hibernate.type.ComponentType) cm
View Full Code Here

    return from(entityClass, EntityUtils.getCommandName(type.getEntityName()));
  }

  @SuppressWarnings("unchecked")
  public static <E> OqlBuilder<E> from(final Class<E> entityClass, final String alias) {
    EntityType type = Model.getEntityType(entityClass.getName());
    if (null == type) {
      type = Model.getEntityType(entityClass);
    }
    OqlBuilder<E> query = new OqlBuilder<E>();
    query.entityClass = (Class<E>) type.getEntityClass();
    query.alias = alias;
    query.select = "select " + alias;
    query.from = concat("from ", type.getEntityName(), " ", alias);
    return query;
  }
View Full Code Here

    super();
    this.statement = hql;
  }

  public EntityQuery(final String entityName, final String alias) {
    EntityType type = Model.getEntityType(entityName);
    this.entityClass = type.getEntityClass();
    this.alias = alias;
    select = "select " + alias + " ";
    from = "from " + entityName + " " + alias;
  }
View Full Code Here

    from = "from " + entityName + " " + alias;
  }

  public EntityQuery(final Class<?> entityClass, final String alias) {
    super();
    EntityType type = Model.getEntityType(entityClass.getName());
    if (null == type) {
      type = Model.getEntityType(entityClass);
    }
    this.entityClass = type.getEntityClass();
    this.alias = alias;
    select = "select " + alias + " ";
    from = "from " + type.getEntityName() + " " + alias;
  }
View Full Code Here

TOP

Related Classes of org.beangle.model.entity.types.EntityType

Copyright © 2018 www.massapicom. 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.