类javax.ejb.FinderException源码实例Demo

下面列出了怎么用javax.ejb.FinderException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: tomee   文件: JpaCmpEngine.java
public List<Object> queryBeans(final BeanContext beanContext, final String signature, final Object[] args) throws FinderException {
    final EntityManager entityManager = getEntityManager(beanContext);

    Query query = createNamedQuery(entityManager, signature);
    if (query == null) {
        final int parenIndex = signature.indexOf('(');
        if (parenIndex > 0) {
            final String shortName = signature.substring(0, parenIndex);
            query = createNamedQuery(entityManager, shortName);
        }
        if (query == null) {
            throw new FinderException("No query defined for method " + signature);
        }
    }
    return executeSelectQuery(query, args);
}
 
源代码2 项目: tomee   文件: EjbSelect.java
public static float execute_float(final Object obj, final String methodSignature, final Object... args) throws FinderException {
    final BeanContext beanContext = (BeanContext) obj;
    final Container container = beanContext.getContainer();
    if (!(container instanceof CmpContainer)) {
        throw new FinderException("Deployment is not connected to a CmpContainer " + beanContext.getDeploymentID());
    }
    final CmpContainer cmpContainer = (CmpContainer) container;

    final Number result = (Number) cmpContainer.select(beanContext, methodSignature, "float", args);
    return result.floatValue();
}
 
源代码3 项目: tomee   文件: EjbSelect.java
public static boolean execute_boolean(final Object obj, final String methodSignature, final Object... args) throws FinderException {
    final BeanContext beanContext = (BeanContext) obj;
    final Container container = beanContext.getContainer();
    if (!(container instanceof CmpContainer)) {
        throw new FinderException("Deployment is not connected to a CmpContainer " + beanContext.getDeploymentID());
    }
    final CmpContainer cmpContainer = (CmpContainer) container;

    final Boolean result = (Boolean) cmpContainer.select(beanContext, methodSignature, "byte", args);
    return result;
}
 
源代码4 项目: tomee   文件: EmployeeBean.java
public Integer ejbFindByPrimaryKey(final Integer primaryKey)
    throws javax.ejb.FinderException {
    boolean found = false;
    try {
        final InitialContext jndiContext = new InitialContext();

        final javax.sql.DataSource ds = (javax.sql.DataSource) jndiContext.lookup("java:comp/env/jdbc/orders");

        final Connection con = ds.getConnection();

        try {
            final PreparedStatement stmt = con.prepareStatement("select * from Employees where EmployeeID = ?");
            try {
                stmt.setInt(1, primaryKey.intValue());
                final ResultSet rs = stmt.executeQuery();
                found = rs.next();
            } finally {
                stmt.close();
            }
        } finally {
            con.close();
        }
    } catch (final Exception e) {
        e.printStackTrace();
        throw new FinderException("FindByPrimaryKey failed");
    }

    if (found)
        return primaryKey;
    else
        throw new javax.ejb.ObjectNotFoundException();


}
 
源代码5 项目: tomee   文件: EjbSelect.java
public static char execute_char(final Object obj, final String methodSignature, final Object... args) throws FinderException {
    final BeanContext beanContext = (BeanContext) obj;
    final Container container = beanContext.getContainer();
    if (!(container instanceof CmpContainer)) {
        throw new FinderException("Deployment is not connected to a CmpContainer " + beanContext.getDeploymentID());
    }
    final CmpContainer cmpContainer = (CmpContainer) container;

    final Character result = (Character) cmpContainer.select(beanContext, methodSignature, "char", args);
    return result;
}
 
源代码6 项目: tomee   文件: EjbSelect.java
public static int execute_int(final Object obj, final String methodSignature, final Object... args) throws FinderException {
    final BeanContext beanContext = (BeanContext) obj;
    final Container container = beanContext.getContainer();
    if (!(container instanceof CmpContainer)) {
        throw new FinderException("Deployment is not connected to a CmpContainer " + beanContext.getDeploymentID());
    }
    final CmpContainer cmpContainer = (CmpContainer) container;

    final Number result = (Number) cmpContainer.select(beanContext, methodSignature, "int", args);
    return result.intValue();
}
 
源代码7 项目: tomee   文件: BasicBmp2DataSourcesBean.java
/**
 * Maps to BasicBmp2DataSourcesHome.findByPrimaryKey
 *
 * @param primaryKey
 * @return Integer
 * @throws javax.ejb.FinderException
 */
public Integer ejbFindByPrimaryKey(final Integer primaryKey)
    throws javax.ejb.FinderException {
    boolean found = false;
    try {
        final InitialContext jndiContext = new InitialContext();
        final DataSource ds = (DataSource) jndiContext.lookup("java:comp/env/jdbc/basic/entityDatabase");
        final Connection con = ds.getConnection();

        try {
            final PreparedStatement stmt = con.prepareStatement("select * from entity where id = ?");
            try {
                stmt.setInt(1, primaryKey.intValue());
                found = stmt.executeQuery().next();
            } finally {
                stmt.close();
            }
        } finally {
            con.close();
        }
    } catch (final Exception e) {
        throw new FinderException("FindByPrimaryKey failed");
    }

    if (found) return primaryKey;
    else throw new javax.ejb.ObjectNotFoundException();
}
 
源代码8 项目: tomee   文件: BasicBmpBean.java
/**
 * Maps to BasicBmpHome.findByPrimaryKey
 *
 * @param lastName
 * @return
 * @throws javax.ejb.FinderException
 * @see BasicBmpHome#sum
 */
public java.util.Collection ejbFindByLastName(final String lastName)
    throws javax.ejb.FinderException {
    final java.util.Vector keys = new java.util.Vector();
    try {
        final InitialContext jndiContext = new InitialContext();
        final DataSource ds = (DataSource) jndiContext.lookup("java:comp/env/jdbc/basic/entityDatabase");
        final Connection con = ds.getConnection();

        try {
            final PreparedStatement stmt = con.prepareStatement("SELECT id FROM entity WHERE last_name = ?");
            try {
                stmt.setString(1, lastName);
                final ResultSet set = stmt.executeQuery();
                while (set.next()) keys.add(new Integer(set.getInt("id")));
            } finally {
                stmt.close();
            }
        } finally {
            con.close();
        }
    } catch (final Exception e) {
        throw new FinderException("FindByPrimaryKey failed");
    }

    if (keys.size() > 0) return keys;
    else throw new javax.ejb.ObjectNotFoundException();
}
 
源代码9 项目: tomee   文件: EjbSelect.java
public static long execute_long(final Object obj, final String methodSignature, final Object... args) throws FinderException {
    final BeanContext beanContext = (BeanContext) obj;
    final Container container = beanContext.getContainer();
    if (!(container instanceof CmpContainer)) {
        throw new FinderException("Deployment is not connected to a CmpContainer " + beanContext.getDeploymentID());
    }
    final CmpContainer cmpContainer = (CmpContainer) container;

    final Number result = (Number) cmpContainer.select(beanContext, methodSignature, "long", args);
    return result.longValue();
}
 
源代码10 项目: tomee   文件: QueryBean.java
/**
 * Select a collection local ejb
 */
public Collection ejbHomeSelectCollectionLocalEjb() throws FinderException {
    return ejbSelectCollectionLocalEjb();
}
 
源代码11 项目: tomee   文件: CmpContainer.java
public int update(final BeanContext beanContext, final String methodSignature, final Object... args) throws FinderException {
    final String signature = beanContext.getAbstractSchemaName() + "." + methodSignature;

    // exectue the update query
    return cmpEngine.executeUpdateQuery(beanContext, signature, args);
}
 
源代码12 项目: tomee   文件: QueryBean.java
/**
 * Select a single boolean field
 */
public boolean ejbHomeSelectSingleBooleanField(final boolean value) throws FinderException {
    return ejbSelectSingleBooleanField(value);
}
 
源代码13 项目: tomee   文件: QueryBean.java
/**
 * Select a collection int field
 */
public Collection ejbHomeSelectCollectionIntField() throws FinderException {
    return ejbSelectCollectionIntField();
}
 
源代码14 项目: dacapobench   文件: TradeWebSoapProxy.java
public AccountDataBean getAccountData(String userID) throws FinderException, RemoteException {
	return convertAccountDataBean(getTrade().getAccountData(userID));
}
 
源代码15 项目: tomee   文件: QueryBean.java
/**
 * Select a single remote ejb
 */
public Object ejbHomeSelectSingleRemoteEjb(final int value) throws FinderException {
    return ejbSelectSingleRemoteEjb(value);
}
 
源代码16 项目: tomee   文件: ManyToManyComplexPkTests.java
private PlatformLocal findPlatform(final int platformId) throws FinderException {
    return platformLocalHome.findByPrimaryKey(new PlatformPk(platformId, "value" + platformId));
}
 
源代码17 项目: tomee   文件: QueryBean.java
/**
 * Select a collection long field
 */
public Collection ejbHomeSelectCollectionLongField() throws FinderException {
    return ejbSelectCollectionLongField();
}
 
源代码18 项目: tomee   文件: QueryBean.java
/**
 * Select a single long field
 */
public long ejbHomeSelectSingleLongField(final long value) throws FinderException {
    return ejbSelectSingleLongField(value);
}
 
源代码19 项目: tomee   文件: ABean.java
public ALocal ejbHomeSelectTest(final String test) throws FinderException {
    return ejbSelectTest(test);
}
 
源代码20 项目: tomee   文件: OneToOneComplexPkTests.java
private PersonLocal findPerson(final int personId) throws FinderException {
    return personLocalHome.findByPrimaryKey(new PersonPk(personId, "value" + personId));
}
 
源代码21 项目: tomee   文件: QueryBean.java
/**
 * Select a single float field
 */
public float ejbHomeSelectSingleFloatField(final float value) throws FinderException {
    return ejbSelectSingleFloatField(value);
}
 
源代码22 项目: tomee   文件: CmpContainer.java
public Object select(final BeanContext beanContext, final String methodSignature, final String returnType, final Object... args) throws FinderException {
    final String signature = beanContext.getAbstractSchemaName() + "." + methodSignature;

    try {
        // execute the select query
        final Collection<Object> results = cmpEngine.queryBeans(beanContext, signature, args);

        //
        // process the results
        //

        // If we need to return a set...
        final Collection<Object> proxies;
        if (returnType.equals("java.util.Set")) {
            // we collect values into a LinkedHashSet to preserve ordering
            proxies = new LinkedHashSet<>();
        } else {
            // otherwise use a simple array list
            proxies = new ArrayList<>();
        }

        final boolean isSingleValued = !returnType.equals("java.util.Collection") && !returnType.equals("java.util.Set");
        ProxyFactory proxyFactory = null;
        for (Object value : results) {
            // if this is a single valued query and we already have results, throw FinderException
            if (isSingleValued && !proxies.isEmpty()) {
                throw new FinderException("The single valued query " + methodSignature + "returned more than one item");
            }

            // if we have an EntityBean, we need to proxy it
            if (value instanceof EntityBean) {
                final EntityBean entityBean = (EntityBean) value;
                if (proxyFactory == null) {
                    final BeanContext result = getBeanContextByClass(entityBean.getClass());
                    if (result != null) {
                        proxyFactory = new ProxyFactory(result);
                    }
                }

                if (proxyFactory != null) {
                    if (beanContext.isRemoteQueryResults(methodSignature)) {
                        value = proxyFactory.createRemoteProxy(entityBean, this);
                    } else {
                        value = proxyFactory.createLocalProxy(entityBean, this);
                    }
                }
            }
            proxies.add(value);
        }

        // if not single valued, return the set
        if (!isSingleValued) {
            return proxies;
        }

        // single valued query that returned no rows, is an exception
        if (proxies.isEmpty()) {
            throw new ObjectNotFoundException();
        }

        // return the single item.... multiple return values was handled in for loop above
        return proxies.iterator().next();
    } catch (final RuntimeException e) {
        throw new EJBException(e);
    }
}
 
源代码23 项目: tomee   文件: QueryLocalHome.java
/**
 * Select a collection remote ejb
 */
public abstract Collection ejbSelectCollectionRemoteEjb(String test) throws FinderException;
 
源代码24 项目: tomee   文件: QueryLocalHome.java
/**
 * Select a single short field
 */
public abstract short ejbSelectSingleShortField(short value) throws FinderException;
 
源代码25 项目: tomee   文件: QueryHome.java
/**
 * Select a single char field
 */
public abstract char selectSingleCharField(char value) throws FinderException, RemoteException;
 
/**
 *
 */
test.TestingEntityLocal findByPrimaryKey(java.lang.String key)  throws javax.ejb.FinderException;
 
源代码27 项目: tomee   文件: QueryHome.java
/**
 * Select a collection boolean field
 */
public abstract Collection selectCollectionBooleanField() throws FinderException, RemoteException;
 
/**
 *
 */
test.TestingEntityRemote findByPrimaryKey(java.lang.String key)  throws javax.ejb.FinderException, java.rmi.RemoteException;
 
源代码29 项目: tomee   文件: QueryLocalHome.java
/**
 * Select a collection short field
 */
public abstract Collection ejbSelectCollectionShortField(short test) throws FinderException;
 
源代码30 项目: tomee   文件: QueryHome.java
/**
 * Select a collection char field
 */
public abstract Collection selectCollectionCharField() throws FinderException, RemoteException;