Package org.hibernate.ejb

Examples of org.hibernate.ejb.HibernateEntityManager


        em.merge(planning);
    }

    @Override
    public List<YFPlanning> getEmployeePlanning(Date startDate, Date endDate, YFEmployee employee) {
        HibernateEntityManager hem = (HibernateEntityManager) em.getDelegate();
        Criteria criteria = hem.getSession().createCriteria(YFPlanning.class);
       
        criteria.add(Restrictions.eq("employee.id", employee.getId()));
        criteria.add(Restrictions.ge("startDate", startDate));
        criteria.add(Restrictions.le("endDate", endDate));
        return criteria.list();
View Full Code Here


        return criteria.list();
    }

    @Override
    public YFPlanning getEmployeeCurrentPlanning(Date now, YFEmployee employee) {
        HibernateEntityManager hem = (HibernateEntityManager) em.getDelegate();
        Criteria criteria = hem.getSession().createCriteria(YFPlanning.class);
       
        criteria.add(Restrictions.eq("employee.id", employee.getId()));
        criteria.add(Restrictions.le("startDate", now));
        criteria.add(Restrictions.ge("endDate", now));
       
View Full Code Here

    @PersistenceContext
    protected EntityManager em;

    @Override
    public List<YFArea> getAreas(long restaurantId) {
        HibernateEntityManager hem = (HibernateEntityManager) em.getDelegate();
        Criteria criteria = hem.getSession().createCriteria(YFArea.class);

        criteria.add(Restrictions.eq("restaurant.id", restaurantId));
        return criteria.list();
    }
View Full Code Here

        return criteria.list();
    }

    @Override
    public YFArea getArea(long areaId, long restaurantId) {
        HibernateEntityManager hem = (HibernateEntityManager) em.getDelegate();
        Criteria criteria = hem.getSession().createCriteria(YFArea.class);

        criteria.add(Restrictions.eq("restaurant.id", restaurantId));
        criteria.add(Restrictions.eq("id", areaId));
        return (YFArea) criteria.uniqueResult();
    }
View Full Code Here

        return em.find(YFDishCategory.class, id);
    }

    @Override
    public List<YFDishCategory> getCurrentDishCategories() {
        HibernateEntityManager hem = (HibernateEntityManager) em.getDelegate();
        Criteria criteria = hem.getSession().createCriteria(YFDishCategory.class);
       
        criteria.createAlias("dishes", "d")
                .createAlias("d.themes", "t")
                .add(Restrictions.eq("t.active", true))
                .addOrder(Order.asc("name"))
View Full Code Here

      String persistenceUnit = configurationMD.getOptionSingleValue(PERSISTENCE_UNIT);

      String populateMembershipTypes = configurationMD.getOptionSingleValue(POPULATE_MEMBERSHIP_TYPES);
      String populateIdentityObjectTypes = configurationMD.getOptionSingleValue(POPULATE_IDENTITY_OBJECT_TYPES);

      HibernateEntityManager em = bootstrapHibernateEntityManager(persistenceUnit);

      // Attribute mappings - helper structures

      for (IdentityObjectTypeMetaData identityObjectTypeMetaData : configurationMD.getSupportedIdentityTypes())
      {
         Set<String> names = new HashSet<String>();
         Map<String, IdentityObjectAttributeMetaData> metadataMap = new HashMap<String, IdentityObjectAttributeMetaData>();
         Map<String, String> reverseMap = new HashMap<String, String>();
         for (IdentityObjectAttributeMetaData attributeMetaData : identityObjectTypeMetaData.getAttributes())
         {
            names.add(attributeMetaData.getName());
            metadataMap.put(attributeMetaData.getName(), attributeMetaData);
            if (attributeMetaData.getStoreMapping() != null)
            {
               reverseMap.put(attributeMetaData.getStoreMapping(), attributeMetaData.getName());
            }
         }

         // Use unmodifiableSet as it'll be exposed directly
         attributeMappings.put(identityObjectTypeMetaData.getName(), Collections.unmodifiableSet(names));

         attributesMetaData.put(identityObjectTypeMetaData.getName(), metadataMap);

         reverseAttributeMappings.put(identityObjectTypeMetaData.getName(), reverseMap);
      }

      attributeMappings = Collections.unmodifiableMap(attributeMappings);

      if (populateMembershipTypes != null && populateMembershipTypes.equalsIgnoreCase("true"))
      {
         List<String> memberships = new LinkedList<String>();

         for (String membership : configurationMD.getSupportedRelationshipTypes())
         {
            memberships.add(membership);
         }

         try
         {
            populateRelationshipTypes(em, memberships.toArray(new String[memberships.size()]));
         }
         catch (Exception e)
         {
            throw new IdentityException("Failed to populate relationship types", e);
         }


      }

      if (populateIdentityObjectTypes != null && populateIdentityObjectTypes.equalsIgnoreCase("true"))
      {
         List<String> types = new LinkedList<String>();

         for (IdentityObjectTypeMetaData metaData : configurationMD.getSupportedIdentityTypes())
         {
            types.add(metaData.getName());
         }

         try
         {
            populateObjectTypes(em, types.toArray(new String[types.size()]));
         }
         catch (Exception e)
         {
            throw new IdentityException("Failed to populate identity object types", e);
         }

      }

      if (supportedCredentialTypes != null && supportedCredentialTypes.size() > 0)
      {
         try
         {
            populateCredentialTypes(em, supportedCredentialTypes.toArray(new String[supportedCredentialTypes.size()]));
         }
         catch (Exception e)
         {
            throw new IdentityException("Failed to populated credential types");
         }
      }

      String realmAware = configurationMD.getOptionSingleValue(IS_REALM_AWARE);

      if (realmAware != null && realmAware.equalsIgnoreCase("true"))
      {
         this.isRealmAware = true;
      }

      String allowNotDefineAttributes = configurationMD.getOptionSingleValue(ALLOW_NOT_DEFINED_ATTRIBUTES);

      if (allowNotDefineAttributes != null && allowNotDefineAttributes.equalsIgnoreCase("true"))
      {
         this.isAllowNotDefinedAttributes = true;
      }

      // Default realm

      HibernateRealm realm = null;

      try
      {

         em.getTransaction().begin();

         realm = (HibernateRealm)em.getSession().
            createCriteria(HibernateRealm.class).add(Restrictions.eq("name", DEFAULT_REALM_NAME)).uniqueResult();

         em.getTransaction().commit();

      }
      catch (HibernateException e)
      {
         // Realm does not exist
View Full Code Here

         throw new IllegalArgumentException("IdentityObject name is null");
      }

      checkIOType(identityObjectType);

      HibernateEntityManager em = getHibernateEntityManager(ctx);

      HibernateRealm realm = getRealm(em, ctx);

      // Check if object with a given name and type is not present already
      List<?> results = em.createNamedQuery("findIdentityObjectByNameAndType")
         .setParameter("realm", realm)
         .setParameter("name", name)
         .setParameter("typeName", identityObjectType.getName())
        .getResultList();
View Full Code Here

   public void removeIdentityObject(IdentityStoreInvocationContext ctx, IdentityObject identity) throws IdentityException
   {
      HibernateIdentityObject hibernateObject = safeGet(ctx, identity);

      HibernateEntityManager hem = getHibernateEntityManager(ctx);

      try
      {
         // Remove all related relationships
         for (HibernateIdentityObjectRelationship relationship : hibernateObject.getFromRelationships())
         {
            relationship.getFromIdentityObject().getFromRelationships().remove(relationship);
            relationship.getToIdentityObject().getToRelationships().remove(relationship);

            hem.remove(relationship);
         }

         for (HibernateIdentityObjectRelationship relationship : hibernateObject.getToRelationships())
         {
            relationship.getFromIdentityObject().getFromRelationships().remove(relationship);
            relationship.getToIdentityObject().getToRelationships().remove(relationship);

            hem.remove(relationship);
         }

         hem.remove(hibernateObject);
      }
      catch (Exception e)
      {
         throw new IdentityException("Cannot remove IdentityObject" + identity, e);
      }
View Full Code Here

   {
      checkIOType(identityType);

      HibernateIdentityObjectType jpaType = getHibernateIdentityObjectType(ctx, identityType);

      HibernateEntityManager em = getHibernateEntityManager(ctx);

      int count;
      try
      {
         count = ((Number)em
            .createNamedQuery("countIdentityObjectsByType")
            .setParameter("typeName", jpaType.getName())
            .setParameter("realm", getRealm(em, ctx))
            .getSingleResult()).intValue();
      }
View Full Code Here

      HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx, type);

      HibernateIdentityObject hibernateObject = null;

      HibernateEntityManager em = getHibernateEntityManager(ctx);

      try
      {
         hibernateObject = (HibernateIdentityObject)getHibernateEntityManager(ctx).
            createNamedQuery("findIdentityObjectByNameAndType")
View Full Code Here

TOP

Related Classes of org.hibernate.ejb.HibernateEntityManager

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.