Package org.hibernate.ejb

Examples of org.hibernate.ejb.HibernateEntityManager


      HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx, identityType);

      List<IdentityObject> results;

      HibernateEntityManager em = getHibernateEntityManager(ctx);

      try
      {

         Query q = null;

         if (sortSearchControl != null)
         {
            if (sortSearchControl.isAscending())
            {
               q = em.createNamedQuery("findIdentityObjectsByTypeOrderedByNameAsc");
            }
            else
            {
               q = em.createNamedQuery("findIdentityObjectsByTypeOrderedByNameDesc");
            }
         }
         else
         {
            q = em.createNamedQuery("findIdentityObjectsByType");
         }

         if (pageSearchControl != null)
         {
            if (pageSearchControl.getLimit() > 0)
View Full Code Here


      if (name == null)
      {
         throw new IllegalArgumentException("name is null");
      }

      HibernateEntityManager em = getHibernateEntityManager(ctx);

      HibernateRealm realm = getRealm(em, ctx);

      try
      {
         HibernateIdentityObjectRelationshipName hiorn = (HibernateIdentityObjectRelationshipName)em.getSession().createCriteria(HibernateIdentityObjectRelationshipName.class)
            .add(Restrictions.eq("name", name)).add(Restrictions.eq("realm", realm)).uniqueResult();

         if (hiorn != null)
         {
            throw new IdentityException("Relationship name already exists");
View Full Code Here

      if (name == null)
      {
         throw new IllegalArgumentException("name is null");
      }

      HibernateEntityManager em = getHibernateEntityManager(ctx);


      try
      {
         HibernateIdentityObjectRelationshipName hiorn = (HibernateIdentityObjectRelationshipName)em.getSession().createCriteria(HibernateIdentityObjectRelationshipName.class)
            .add(Restrictions.eq("name", name)).add(Restrictions.eq("realm", getRealm(em, ctx))).uniqueResult();

         if (hiorn == null)
         {
            throw new IdentityException("Relationship name doesn't exist");
View Full Code Here

   public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObjectSearchControl[] controls) throws IdentityException, OperationNotSupportedException
   {

      Set<String> names = new HashSet<String>();

      HibernateEntityManager em = getHibernateEntityManager(ctx);

      checkControls(controls);

      PageSearchControl pageSearchControl = null;
      SortByNameSearchControl sortSearchControl = null;
      AttributeFilterSearchControl attributeFilterControl = null;
      NameFilterSearchControl nameFilterSearchControl = null;

      if (controls != null)
      {
         for (IdentityObjectSearchControl control : controls)
         {
            if (control instanceof PageSearchControl)
            {
               pageSearchControl = (PageSearchControl)control;
            }
            else if (control instanceof SortByNameSearchControl)
            {
               sortSearchControl = (SortByNameSearchControl)control;
            }
            else if (control instanceof AttributeFilterSearchControl)
            {
               attributeFilterControl = (AttributeFilterSearchControl)control;
            }
            else if (control instanceof NameFilterSearchControl)
            {
               nameFilterSearchControl = (NameFilterSearchControl)control;
            }
         }
      }


      try
      {
         Query q = null;

         if (sortSearchControl != null)
         {
            if (sortSearchControl.isAscending())
            {
               q = em.createNamedQuery("findIdentityObjectRelationshipNamesOrderedByNameAsc");
            }
            else
            {
               q = em.createNamedQuery("findIdentityObjectRelationshipNamesOrderedByNameDesc");
            }
         }
         else
         {
            q = em.createNamedQuery("findIdentityObjectRelationshipNames");
         }

         q.setParameter("realm", getRealm(em, ctx));

         if (nameFilterSearchControl != null)
View Full Code Here

      Set<String> names;

      HibernateIdentityObject hibernateObject = safeGet(ctx, identity);

      HibernateEntityManager em = getHibernateEntityManager(ctx);

      checkControls(controls);

      PageSearchControl pageSearchControl = null;
      SortByNameSearchControl sortSearchControl = null;

      if (controls != null)
      {
         for (IdentityObjectSearchControl control : controls)
         {
            if (control instanceof PageSearchControl)
            {
               pageSearchControl = (PageSearchControl)control;
            }
            else if (control instanceof SortByNameSearchControl)
            {
               sortSearchControl = (SortByNameSearchControl)control;
            }
         }
      }

      try
      {
         Query q = null;

         if (sortSearchControl != null)
         {
            if (sortSearchControl.isAscending())
            {
               q = em.createNamedQuery("findIdentityObjectRelationshipNamesForIdentityObjectOrderedByNameAsc");
            }
            else
            {
               q = em.createNamedQuery("findIdentityObjectRelationshipNamesForIdentityObjectOrderedByNameDesc");
            }
         }
         else
         {
            q = em.createNamedQuery("findIdentityObjectRelationshipNamesForIdentityObject");
         }

         q.setParameter("identityObject", hibernateObject);

         if (pageSearchControl != null)
View Full Code Here

         throw new IllegalArgumentException();
      }

      HibernateIdentityObject hibernateObject = safeGet(ctx, identityObject);

      HibernateEntityManager em = getHibernateEntityManager(ctx);

      if (supportedFeatures.isCredentialSupported(hibernateObject.getIdentityType(),credential.getType()))
      {

         HibernateIdentityObjectCredentialType hibernateCredentialType = getHibernateIdentityObjectCredentialType(ctx, credential.getType());

         if (hibernateCredentialType == null)
         {
            throw new IllegalStateException("Credential type not present in this store: " + credential.getType().getName());
         }

         HibernateIdentityObjectCredential hibernateCredential = new HibernateIdentityObjectCredential();
         hibernateCredential.setIdentityObject(hibernateObject);
         hibernateCredential.setType(hibernateCredentialType);

         Object value = null;

         // Handle generic impl

         if (credential.getEncodedValue() != null)
         {
            value = credential.getEncodedValue();
         }
         else
         {
            //TODO: support for empty password should be configurable
            value = credential.getValue();
         }

         if (value instanceof String)
         {
            hibernateCredential.setTextValue(value.toString());
         }
         else if (value instanceof byte[])
         {
            hibernateCredential.setBinaryValue((byte[])value);
         }
         else
         {
            throw new IdentityException("Not supported credential value: " + value.getClass());
         }

         em.persist(hibernateCredential);

         hibernateObject.addCredential(hibernateCredential);

      }
      else
View Full Code Here

   private HibernateIdentityObjectType getHibernateIdentityObjectType(IdentityStoreInvocationContext ctx, IdentityObjectType type) throws IdentityException
   {

      HibernateIdentityObjectType hibernateType = null;

      HibernateEntityManager em = getHibernateEntityManager(ctx);


      try
      {
         hibernateType = (HibernateIdentityObjectType)em.createNamedQuery("findIdentityObjectTypeByName")
            .setParameter("name", type.getName())
            .getSingleResult() ;
      }
      catch (NoResultException e)
      {
View Full Code Here

   private HibernateIdentityObject getHibernateIdentityObject(IdentityStoreInvocationContext ctx, IdentityObject io) throws IdentityException
   {

      HibernateIdentityObject hibernateObject = null;

      HibernateEntityManager em = getHibernateEntityManager(ctx);


      try
      {
         hibernateObject = (HibernateIdentityObject)em.createNamedQuery("findIdentityObjectByNameAndType")
            .setParameter("name", io.getName())
            .setParameter("typeName", io.getIdentityType().getName())
            .setParameter("realm", getRealm(em, ctx))
            .getSingleResult();
      }
View Full Code Here

   private HibernateIdentityObjectRelationshipType getHibernateIdentityObjectRelationshipType(IdentityStoreInvocationContext ctx, IdentityObjectRelationshipType iot) throws IdentityException
   {

      HibernateIdentityObjectRelationshipType relationshipType = null;

      HibernateEntityManager em = getHibernateEntityManager(ctx);

      try
      {
         relationshipType = (HibernateIdentityObjectRelationshipType)em.createNamedQuery("findIdentityObjectRelationshipTypeByName")
            .setParameter("name", iot.getName())
            .getSingleResult();
      }
      catch (Exception e)
      {
View Full Code Here

      return relationshipType;
   }

   private HibernateIdentityObjectCredentialType getHibernateIdentityObjectCredentialType(IdentityStoreInvocationContext ctx, IdentityObjectCredentialType credentialType) throws IdentityException
   {
      HibernateEntityManager em = getHibernateEntityManager(ctx);

      HibernateIdentityObjectCredentialType hibernateType = null;

      try
      {
          hibernateType = (HibernateIdentityObjectCredentialType)em.getSession().
               createCriteria(HibernateIdentityObjectCredentialType.class).add(Restrictions.eq("name", credentialType.getName())).uniqueResult();
      }
      catch (HibernateException e)
      {
         throw new IdentityException("IdentityObjectCredentialType[ " + credentialType.getName() + "] not present in the store.");
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.