container/profiles/src/main/java/org/mobicents/slee/container/deployment/profile/jpa/JPAProfileEntityFramework.java
@SuppressWarnings("unchecked")
	public Collection<ProfileEntity> getProfilesByStaticQuery(
			String profileTable, String queryName, final Object[] parameters)
			throws NullPointerException, UnrecognizedQueryNameException,
			AttributeTypeMismatchException, InvalidArgumentException {

		// TODO check for exceptions

		final QueryWrapper wQuery = JPAQueryBuilder.getQuery(queryName);

		final EntityManager em = getEntityManager();

		if(System.getSecurityManager()==null)
		{
		Query staticQuery = em.createQuery(wQuery
				.getQuerySQL(profileEntityClassName));

		if (wQuery.getMaxMatches() > 0)
			staticQuery.setMaxResults((int) wQuery.getMaxMatches());

		for (int i = 0; i < parameters.length; i++) {
			try {
				staticQuery.setParameter(i + 1, parameters[i]);
			} catch (Exception ignore) {
				// We don't care, it's because there's no such parameter.
			}
		}

		return staticQuery.getResultList();
		}else
		{
			try {
				return AccessController.doPrivileged(new PrivilegedExceptionAction<Collection<ProfileEntity>>(){

					public Collection<ProfileEntity> run() throws Exception {
						Query staticQuery = em.createQuery(wQuery
								.getQuerySQL(profileEntityClassName));

						if (wQuery.getMaxMatches() > 0)
							staticQuery.setMaxResults((int) wQuery.getMaxMatches());

						for (int i = 0; i < parameters.length; i++) {
							try {
								staticQuery.setParameter(i + 1, parameters[i]);
							} catch (Exception ignore) {
								// We don't care, it's because there's no such parameter.
							}
						}

						return staticQuery.getResultList();
					}});
			} catch (PrivilegedActionException e) {
				Throwable t = e.getCause();
				if(t instanceof NullPointerException)
					throw (NullPointerException )t;
				if(t instanceof UnrecognizedQueryNameException)
					throw (UnrecognizedQueryNameException )t;
				if(t instanceof AttributeTypeMismatchException)
					throw (AttributeTypeMismatchException )t;
				if(t instanceof InvalidArgumentException)
					throw (InvalidArgumentException )t;
				
				//?
				throw new SLEEException("",t);
				
			}
		}

	}
@SuppressWarnings("unchecked")
	public Collection<ProfileEntity> getProfilesByStaticQuery(
			String profileTable, String queryName, final Object[] parameters)
			throws NullPointerException, UnrecognizedQueryNameException,
			AttributeTypeMismatchException, InvalidArgumentException {

		// TODO check for exceptions

		final QueryWrapper wQuery = JPAQueryBuilder.getQuery(queryName);

		final EntityManager em = getEntityManager();

		if(System.getSecurityManager()==null)
		{
		Query staticQuery = em.createQuery(wQuery
				.getQuerySQL(profileEntityClassName));

		if (wQuery.getMaxMatches() > 0)
			staticQuery.setMaxResults((int) wQuery.getMaxMatches());

		for (int i = 0; i < parameters.length; i++) {
			try {
				staticQuery.setParameter(i + 1, parameters[i]);
			} catch (Exception ignore) {
				// We don't care, it's because there's no such parameter.
			}
		}

		return staticQuery.getResultList();
		}else
		{
			try {
				return AccessController.doPrivileged(new PrivilegedExceptionAction<Collection<ProfileEntity>>(){

					public Collection<ProfileEntity> run() throws Exception {
						Query staticQuery = em.createQuery(wQuery
								.getQuerySQL(profileEntityClassName));

						if (wQuery.getMaxMatches() > 0)
							staticQuery.setMaxResults((int) wQuery.getMaxMatches());

						for (int i = 0; i < parameters.length; i++) {
							try {
								staticQuery.setParameter(i + 1, parameters[i]);
							} catch (Exception ignore) {
								// We don't care, it's because there's no such parameter.
							}
						}

						return staticQuery.getResultList();
					}});
			} catch (PrivilegedActionException e) {
				Throwable t = e.getCause();
				if(t instanceof NullPointerException)
					throw (NullPointerException )t;
				if(t instanceof UnrecognizedQueryNameException)
					throw (UnrecognizedQueryNameException )t;
				if(t instanceof AttributeTypeMismatchException)
					throw (AttributeTypeMismatchException )t;
				if(t instanceof InvalidArgumentException)
					throw (InvalidArgumentException )t;
				
				//?
				throw new SLEEException("",t);
				
			}
		}

	}
@ SuppressWarnings ( "unchecked" ) public Collection < ProfileEntity > getProfilesByStaticQuery ( String profileTable , String queryName , final Object [ ] parameters ) throws NullPointerException , UnrecognizedQueryNameException , AttributeTypeMismatchException , InvalidArgumentException { // TODO check for exceptions final QueryWrapper wQuery = JPAQueryBuilder . getQuery ( queryName ) ; final EntityManager em = getEntityManager ( ) ; if ( System . getSecurityManager ( ) == null ) { Query staticQuery = em . createQuery ( wQuery . getQuerySQL ( profileEntityClassName ) ) ; if ( wQuery . getMaxMatches ( ) > 0 ) staticQuery . setMaxResults ( ( int ) wQuery . getMaxMatches ( ) ) ; for ( int i = 0 ; i < parameters . length ; i ++ ) { try { staticQuery . setParameter ( i + 1 , parameters [ i ] ) ; } catch ( Exception ignore ) { // We don't care, it's because there's no such parameter. } } return staticQuery . getResultList ( ) ; } else { try { return AccessController . doPrivileged ( new PrivilegedExceptionAction < Collection < ProfileEntity > > ( ) { public Collection < ProfileEntity > run ( ) throws Exception { Query staticQuery = em . createQuery ( wQuery . getQuerySQL ( profileEntityClassName ) ) ; if ( wQuery . getMaxMatches ( ) > 0 ) staticQuery . setMaxResults ( ( int ) wQuery . getMaxMatches ( ) ) ; for ( int i = 0 ; i < parameters . length ; i ++ ) { try { staticQuery . setParameter ( i + 1 , parameters [ i ] ) ; } catch ( Exception ignore ) { // We don't care, it's because there's no such parameter. } } return staticQuery . getResultList ( ) ; } } ) ; } catch ( PrivilegedActionException e ) { Throwable t = e . getCause ( ) ; if ( t instanceof NullPointerException ) throw ( NullPointerException ) t ; if ( t instanceof UnrecognizedQueryNameException ) throw ( UnrecognizedQueryNameException ) t ; if ( t instanceof AttributeTypeMismatchException ) throw ( AttributeTypeMismatchException ) t ; if ( t instanceof InvalidArgumentException ) throw ( InvalidArgumentException ) t ; //? throw new SLEEException ( "" , t ) ; } } }
/*
(non-Javadoc)

@see
org.mobicents.slee.container.component.profile.ProfileEntityFramework
#getProfilesByStaticQuery(java.lang.String, java.lang.String,
java.lang.Object[])
/ * ( non - Javadoc )