Examples of Metamodel


Examples of javax.persistence.metamodel.Metamodel

        {
            final EntityManagerFactory emf = entityManagerSource.getEntityManagerFactory(info.getPersistenceUnitName());

            for (final String className : info.getManagedClassNames())
            {
                final Metamodel metamodel = emf.getMetamodel();

                final Class<?> clazz = loadClass(info, className);

                final EntityType<?> entity = metamodel.entity(clazz);

                final ValueEncoderFactory factory = new ValueEncoderFactory()
                {
                    public ValueEncoder create(final Class type)
                    {
View Full Code Here

Examples of javax.persistence.metamodel.Metamodel

        assertEquivalence(c, jpql);
       
    }
   
    public void testDisjunctionAsFalse() {
        Metamodel mm = em.getMetamodel();

        CriteriaQuery<Order> cquery = cb.createQuery(Order.class);
        Root<Order> order = cquery.from(Order.class);
       
       EntityType<Order> Order_ = order.getModel();
       EntityType<Customer> Customer_ = mm.entity(Customer.class);
       cquery.where(cb.and(cb.equal(
         order.get(Order_.getSingularAttribute("customer", Customer.class))
                  .get(Customer_.getSingularAttribute("name", String.class)), "Robert E. Bissett"),
         cb.isFalse(cb.disjunction())));
View Full Code Here

Examples of javax.persistence.metamodel.Metamodel

    // NOTE turns entityPath in collection into entityPath.id in (collection
    // of ids)
    if (entityManager != null && args.get(0).getType().isAnnotationPresent(Entity.class)) {
      Path<?> lhs = (Path<?>) args.get(0);
      Constant<?> rhs = (Constant<?>) args.get(1);
      Metamodel metamodel = entityManager.getMetamodel();
      PersistenceUnitUtil util = entityManager.getEntityManagerFactory().getPersistenceUnitUtil();
      EntityType<?> entityType = metamodel.entity(args.get(0).getType());
      if (entityType.hasSingleIdAttribute()) {
        SingularAttribute<?, ?> id = getIdProperty(entityType);
        // turn lhs into id path
        lhs = new PathImpl(id.getJavaType(), lhs, id.getName());
        // turn rhs into id collection
View Full Code Here

Examples of javax.persistence.metamodel.Metamodel

      if (entityClassCache.containsKey(className)) {
    return entityClassCache.get(className);
      }

      EntityManager em = factory.createEntityManager();
      Metamodel meta = em.getMetamodel();

      for (EntityType<?> et : meta.getEntities()) {
    if (et.getJavaType().getName().endsWith("." + className)) {
        Class<?> clazz = et.getJavaType();
        entityClassCache.put(className, clazz);
        return clazz;
    }
View Full Code Here

Examples of javax.persistence.metamodel.Metamodel

    EntityManager em = null;

    try {
      em = this.factory.createEntityManager();
      Metamodel meta = em.getMetamodel();
      for (EntityType<?> et : meta.getEntities()) {
        if (et.getJavaType().getName().endsWith("." + className)) {
          Class<?> clazz = et.getJavaType();
          entityClassCache.put(className, clazz);
          return clazz;
        }
View Full Code Here

Examples of javax.persistence.metamodel.Metamodel

      if (entityClassCache.containsKey(className)) {
    return entityClassCache.get(className);
      }

      EntityManager em = factory.createEntityManager();
      Metamodel meta = em.getMetamodel();

      for (EntityType<?> et : meta.getEntities()) {
    if (et.getJavaType().getName().endsWith("." + className)) {
        Class<?> clazz = et.getJavaType();
        entityClassCache.put(className, clazz);
        return clazz;
    }
View Full Code Here

Examples of javax.persistence.metamodel.Metamodel

      if (entityClassCache.containsKey(className)) {
    return entityClassCache.get(className);
      }

      EntityManager em = factory.createEntityManager();
      Metamodel meta = em.getMetamodel();

      for (EntityType<?> et : meta.getEntities()) {
    if (et.getJavaType().getName().endsWith("." + className)) {
        Class<?> clazz = et.getJavaType();
        entityClassCache.put(className, clazz);
        return clazz;
    }
View Full Code Here

Examples of javax.persistence.metamodel.Metamodel

   * @return DataMartModelStructure
   */
  public IModelStructure build() {
    ModelStructure modelStructure;
    String modelName;
    Metamodel jpaMetamodel;
    Set<EntityType<?>> jpaEntities;
   
    logger.debug("IN");
   
    try {
      modelStructure = new ModelStructure();
 
      modelName = getDataSource().getConfiguration().getModelName();
      Assert.assertNotNull(getDataSource(), "datasource cannot be null")
      setEntityManager(getDataSource().getEntityManager());
      Assert.assertNotNull(getEntityManager(), "Impossible to find the jar file associated to datamart named: [" + modelName + "]");
     
     
      propertiesInitializer.addProperties(modelStructure)
      Map calculatedFields = getDataSource().getConfiguration().loadCalculatedFields();
      modelStructure.setCalculatedFields(calculatedFields);
       
      jpaMetamodel = getEntityManager().getMetamodel();   
      jpaEntities = jpaMetamodel.getEntities();
      logger.debug("Jpa metamodel contains ["+ jpaEntities.size() + "] entity types");
     
      for(EntityType<?> entityType: jpaEntities) {
        logger.debug("Adding entity type [" + entityType + "] to model structure");
        String entityTypeName =  entityType.getJavaType().getName();
View Full Code Here

Examples of javax.persistence.metamodel.Metamodel

    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

Examples of javax.persistence.metamodel.Metamodel

   * @param entityAlias the alias of the table
   */
  public void addTableFakeCondition(String datamartEntityName, String entityAlias){
    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)){
       
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.