Package javax.persistence.metamodel

Examples of javax.persistence.metamodel.EntityType


          "Applying named entity graph [name=%s, entity-name=%s, jpa-entity-name=%s",
          definition.getRegisteredName(),
          definition.getEntityName(),
          definition.getJpaEntityName()
      );
      final EntityType entityType = metamodel.getEntityTypeByName( definition.getEntityName() );
      if ( entityType == null ) {
        throw new IllegalArgumentException(
            "Attempted to register named entity graph [" + definition.getRegisteredName()
                + "] for unknown entity ["+ definition.getEntityName() + "]"

        );
      }
      final EntityGraphImpl entityGraph = new EntityGraphImpl(
          definition.getRegisteredName(),
          entityType,
          this
      );

      final NamedEntityGraph namedEntityGraph = definition.getAnnotation();

      if ( namedEntityGraph.includeAllAttributes() ) {
        for ( Object attributeObject : entityType.getAttributes() ) {
          entityGraph.addAttributeNodes( (Attribute) attributeObject );
        }
      }

      if ( namedEntityGraph.attributeNodes() != null ) {
View Full Code Here


        From lastRoot = root;

        // walk through associations
        for (int i = 0; i < path.length - 1; i++)
        {
            EntityType metadata = parent.getEntityType(lastRoot.getJavaType());
            property = parent.getMapper().translate(path[i], lastRoot.getJavaType());

            if (!isPropertyName(property, metadata))
            {
                throw new UnknownSelectorException(path[i]);
            }

            lastRoot = lastRoot.join(property);

            logger.trace("Nesting level {}: property '{}' of entity {}",
                    new Object[]{i, property, metadata.getJavaType().getSimpleName()});

        }

        // the last property may by an ordinal property (not an association)
        property = parent.getMapper().translate(path[path.length - 1], lastRoot.getJavaType());
View Full Code Here

    public Predicate createPredicate(String property, Comparison operator, String argument, From root,
                                     ExpressionPredicateBuilder parent)
            throws ArgumentFormatException, UnknownSelectorException
    {

        EntityType metadata = parent.getEntityType(root.getJavaType());
        if (!isPropertyName(property, metadata))
        {
            throw new UnknownSelectorException(property);
        }
View Full Code Here

   */
  public List addNormalFields(IModelEntity dataMartEntity) {   
    logger.debug("Adding the field "+dataMartEntity.getName());
    String[] propertyNames;
    List subEntities = new ArrayList();     
    EntityType thisEntityType = null;
   
    Metamodel classMetadata = getEntityManager().getMetamodel();
   
    for(Iterator it = classMetadata.getEntities().iterator(); it.hasNext(); ) {
      EntityType et = (EntityType)it.next();
      if(et.getJavaType().getName().equals(dataMartEntity.getType())){
        thisEntityType = et;
        break;
      }
    } 
   
View Full Code Here

    if(getDataSource() instanceof org.eclipse.persistence.jpa.JpaEntityManager){//check if the provider is eclipse link
      EntityManager entityManager = ((IJpaDataSource)getDataSource()).getEntityManager();
      Metamodel classMetadata =  entityManager.getMetamodel();
      //search the EntityType of the datamartEntityName
      for(Iterator it2 = classMetadata.getEntities().iterator(); it2.hasNext(); ) {
        EntityType et = (EntityType)it2.next();
        String entityName = et.getName();
       
        if(datamartEntityName.equals(entityName)){
       
          Type keyT = et.getIdType();
         
          if (keyT instanceof BasicType) {
            //the key has only one field
           
            String name = (et.getId(Object.class)).getName();
            if(whereClause==null || whereClause.equals("")){
              whereClause = "WHERE ";
            }else{
              whereClause = whereClause+" AND ";
            }
            whereClause = whereClause + " "+ entityAlias+"."+name+"="+entityAlias+"."+name;
          }else if (keyT instanceof EmbeddableType) {
            //the key is a composed key
            String keyName = (et.getId(Object.class)).getName();
            SingularAttribute keyAttr = (SingularAttribute)(((EmbeddableType) keyT).getDeclaredSingularAttributes().iterator().next());
            String name = keyName+"."+keyAttr.getName();
            if(whereClause==null || whereClause.equals("")){
              whereClause = "WHERE ";
            }else{
View Full Code Here

          "Applying named entity graph [name=%s, entity-name=%s, jpa-entity-name=%s",
          definition.getRegisteredName(),
          definition.getEntityName(),
          definition.getJpaEntityName()
      );
      final EntityType entityType = metamodel.getEntityTypeByName( definition.getEntityName() );
      if ( entityType == null ) {
        throw new IllegalArgumentException(
            "Attempted to register named entity graph [" + definition.getRegisteredName()
                + "] for unknown entity ["+ definition.getEntityName() + "]"

        );
      }
      final EntityGraphImpl entityGraph = new EntityGraphImpl(
          definition.getRegisteredName(),
          entityType,
          this
      );

      final NamedEntityGraph namedEntityGraph = definition.getAnnotation();

      if ( namedEntityGraph.includeAllAttributes() ) {
        for ( Object attributeObject : entityType.getAttributes() ) {
          entityGraph.addAttributeNodes( (Attribute) attributeObject );
        }
      }

      if ( namedEntityGraph.attributeNodes() != null ) {
View Full Code Here

     * @param entityClass
     *            the entity class
     * @return query root corresponding to the given entity
     */
    public Root internalFrom(Class entityClass) {
        EntityType entity = this.metamodel.entity(entityClass);
        return this.internalFrom(entity);
    }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  private void applyNamedEntityGraphs(Collection<NamedEntityGraphDefinition> namedEntityGraphs) {
    for ( NamedEntityGraphDefinition definition : namedEntityGraphs ) {
      final EntityType entityType = metamodel.getEntityTypeByName( definition.getJpaEntityName() );
      final EntityGraphImpl entityGraph = new EntityGraphImpl(
          definition.getRegisteredName(),
          entityType,
          this
      );

      final NamedEntityGraph namedEntityGraph = definition.getAnnotation();

      if ( namedEntityGraph.includeAllAttributes() ) {
        for ( Object attributeObject : entityType.getAttributes() ) {
          entityGraph.addAttributeNodes( (Attribute) attributeObject );
        }
      }

      if ( namedEntityGraph.attributeNodes() != null ) {
View Full Code Here

     * @param entityClass
     *            the entity class
     * @return query root corresponding to the given entity
     */
    public Root internalFrom(Class entityClass) {
        EntityType entity = this.metamodel.entity(entityClass);
        return this.internalFrom(entity);
    }
View Full Code Here

    @Override
    public Root<T> getRoot() {
      if (this.root == null) {
          if (getResultType() !=null) {
              EntityType entity = this.metamodel.entity(this.queryType);
              RootImpl newRoot = new RootImpl(entity, this.metamodel, this.queryType, query.getExpressionBuilder(), entity);
              this.root = newRoot;
          }
      }
      return this.root;
View Full Code Here

TOP

Related Classes of javax.persistence.metamodel.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.