Below is the method. The actual query will resolve to:

"FROM DevicePolicy devicePolicy WHERE devicePolicy.device = :device"


  |     public Collection<DevicePolicy> findDevicePoliciesByDevice(Device 
device, boolean includeDeleted, EagerOnDemand onDemand) throws 
LocalizableException {
  |         String alias = DevicePolicy.ROOT.getAlias();
  |         String from = Helper.getEagerFromClause(DevicePolicy.ROOT, 
onDemand);
  |         String deletedClause = includeDeleted ? "" : " AND " + alias + 
".deleted = false ";
  |         try {
  |             Collection<DevicePolicy> list = (Collection<DevicePolicy>) 
entityMgr.createQuery(from +
  |                     " WHERE " + alias + ".device = :device" + deletedClause)
  |                     .setParameter("device", device)
  |                     .getResultList();
  |             EagerOnDemand.loadRelationships(list, onDemand);
  |             return list;
  |         }
  |         catch (Exception e) {
  |             logger.error("Unexpected Error", e);
  |             throw new 
LocalizableException(ServerErrors.ERROR_UNEXPECTED_F1, e, e.getMessage());
  |         }
  |     }
  | 

The PolicyFinder superinterface and PolicyFinderRemote interface that expose 
this method are below:

  | /*
  |  * Copyright (c) 2005 Looking Glass Systems, Inc. All Rights Reserved.
  |  */
  | package net.lgsystems.policy.ejb;
  | 
  | import javax.ejb.Remote;
  | 
  | /**
  |  * <p/>
  |  *
  |  * @author Jon Wynett
  |  *         Created: Nov 17, 2005 10:19:20 AM
  |  */
  | @Remote
  | public interface PolicyFinderRemote extends PolicyFinder {
  | }
  | 

  | /*
  |  * Copyright (c) 2005 Looking Glass Systems, Inc. All Rights Reserved.
  |  */
  | package net.lgsystems.policy.ejb;
  | 
  | import net.lgsystems.network.entity.Device;
  | import net.lgsystems.policy.entity.DevicePolicy;
  | import net.lgsystems.policy.entity.Policy;
  | import net.lgsystems.policy.entity.PolicyGroup;
  | import net.lgsystems.policy.util.PolicyType;
  | import net.lgsystems.util.EagerOnDemand;
  | import net.lgsystems.util.LocalizableException;
  | 
  | import java.util.Collection;
  | 
  | /**
  |  * <p/>
  |  *
  |  * @author Jon Wynett
  |  *         Created: Nov 17, 2005 10:18:37 AM
  |  */
  | public interface PolicyFinder {
  | 
  |     /**
  |      * Find a policy entity by its primary key.
  |      *
  |      * @param policyId
  |      * @param onDemand
  |      * @return Policy
  |      * @throws LocalizableException
  |      */
  |     public Policy findPolicyById(long policyId, EagerOnDemand onDemand) 
throws LocalizableException;
  | 
  |     /**
  |      * Find a policy entity by its display name. This is a unique field
  |      *
  |      * @param displayName
  |      * @param onDemand
  |      * @return Policy
  |      * @throws LocalizableException
  |      */
  |     public Policy findPolicyByName(String displayName, EagerOnDemand 
onDemand) throws LocalizableException;
  | 
  |     /**
  |      * Find a collection of policies by the PolicyType.
  |      *
  |      * @param policyType
  |      * @param onDemand
  |      * @return Policy
  |      * @throws LocalizableException
  |      */
  |     public Collection<Policy> findPoliciesByType(PolicyType policyType, 
EagerOnDemand onDemand) throws LocalizableException;
  | 
  |     /**
  |      * Get all the policies assigned to a given device. This list can be 
filtered. If not filtered, every single re
  |      * @param deviceId
  |      * @param filtered
  |      * @param onDemand
  |      * @return
  |      * @throws LocalizableException
  |      */
  |     //public Collection<Policy> getPoliciesForDevice(long deviceId, boolean 
filtered, EagerOnDemand onDemand) throws LocalizableException;
  | 
  |     /**
  |      * Retrieve all policy entities.
  |      *
  |      * @param onDemand
  |      * @return Collection<Policy>
  |      */
  |     public Collection<Policy> getPolicies(EagerOnDemand onDemand);
  | 
  |     /**
  |      * Find a policy group entity by its primary key.
  |      *
  |      * @param policyGroupId
  |      * @param onDemand
  |      * @return PolicyGroup
  |      * @throws LocalizableException
  |      */
  |     public PolicyGroup findPolicyGroupById(long policyGroupId, 
EagerOnDemand onDemand) throws LocalizableException;
  | 
  |     /**
  |      * Find a policyGroup entity by its group name. This is a unique field
  |      *
  |      * @param groupName
  |      * @param onDemand
  |      * @return PolicyGroup
  |      * @throws LocalizableException
  |      */
  |     public PolicyGroup findPolicyGroupByName(String groupName, 
EagerOnDemand onDemand) throws LocalizableException;
  | 
  |     /**
  |      * Retrieve all policyGroup entities.
  |      *
  |      * @param onDemand
  |      * @return Collection<PolicyGroup>
  |      */
  |     public Collection<PolicyGroup> getPolicyGroups(EagerOnDemand onDemand);
  | 
  |     /**
  |      * Find devicePolicy entities for a given policy.
  |      *
  |      * @param policy
  |      * @param onDemand
  |      * @return Collection<DevicePolicy>
  |      * @throws net.lgsystems.util.LocalizableException
  |      *
  |      */
  |     public Collection<DevicePolicy> findDevicePoliciesByPolicy(Policy 
policy) throws LocalizableException;
  | 
  |     /**
  |      * Find a devicePolicy entity by its primary key.
  |      *
  |      * @param devicePolicyId
  |      * @param onDemand
  |      * @return DevicePolicy
  |      * @throws LocalizableException
  |      */
  |     public DevicePolicy findDevicePolicyById(long devicePolicyId, 
EagerOnDemand onDemand) throws LocalizableException;
  | 
  |     /**
  |      * Get all devicePolicy entities.
  |      *
  |      * @param onDemand
  |      * @return Collection<DevicePolicy>
  |      */
  |     public Collection<DevicePolicy> getDevicePolicies(EagerOnDemand 
onDemand);
  | 
  |     /**
  |      * Finds a DevicePolicy entity by its unique key, device and policy.
  |      *
  |      * @param device
  |      * @param policy
  |      * @param includeDeleted true to include all records. false to exclude 
those marked for deletion
  |      * @param onDemand
  |      * @return DevicePolicy
  |      * @throws LocalizableException
  |      */
  |     public DevicePolicy findDevicePolicyByDeviceAndPolicy(Device device, 
Policy policy, boolean includeDeleted, EagerOnDemand onDemand) throws 
LocalizableException;
  | 
  |     /**
  |      * Finds a list of DevicePolicy entities by device.
  |      *
  |      * @param device
  |      * @param includeDeleted true to include all records. false to exclude 
those marked for deletion
  |      * @param onDemand
  |      * @return Collection<DevicePolicy>
  |      */
  |     public Collection<DevicePolicy> findDevicePoliciesByDevice(Device 
device, boolean includeDeleted, EagerOnDemand onDemand) throws 
LocalizableException;
  | 
  |     /**
  |      * Returns all the Policies for a given device filtered by override 
status returning only
  |      * the policies that should be active.
  |      *
  |      * @param device
  |      * @return Collection<Policy>
  |      * @throws LocalizableException
  |      */
  |     public Collection<Policy> findFilteredPoliciesForDevice(Device device) 
throws LocalizableException;
  | }

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3925714#3925714

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3925714


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to