/** * <p>Returns an array of entities of the specified type corresponding to the * varargs primary keys. If an in-memory reference already exists to a corresponding * entity (of the specified type and key), it is returned rather than creating * a new instance.</p> * * <p>If the entity is known to exist in the database, then no checks are performed * and the method returns extremely quickly. However, for any key which has not * already been verified, a query to the database is performed to determine whether * or not the entity exists. If the entity does not exist, then <code>null</code> * is returned.</p> * * @param type The type of the entities to retrieve. * @param keys The primary keys corresponding to the entities to retrieve. All * keys must be typed according to the generic type parameter of the entity's * {@link RawEntity} inheritence (if inheriting from {@link Entity}, this is <code>Integer</code> * or <code>int</code>). Thus, the <code>keys</code> array is type-checked at compile * time. * @return An array of entities of the given type corresponding with the specified * primary keys. Any entities which are non-existent will correspond to a <code>null</code> * value in the resulting array. */ public <T extends RawEntity<K>, K> T[] get(final Class<T> type, K... keys) throws SQLException { EntityInfo<T, K> entityInfo = resolveEntityInfo(type); final String primaryKeyField = entityInfo.getPrimaryKey().getName(); return get(type, findByPrimaryKey(type, primaryKeyField), keys); }
/** * <p>Returns an array of entities of the specified type corresponding to the * varargs primary keys. If an in-memory reference already exists to a corresponding * entity (of the specified type and key), it is returned rather than creating * a new instance.</p> * * <p>If the entity is known to exist in the database, then no checks are performed * and the method returns extremely quickly. However, for any key which has not * already been verified, a query to the database is performed to determine whether * or not the entity exists. If the entity does not exist, then <code>null</code> * is returned.</p> * * @param type The type of the entities to retrieve. * @param keys The primary keys corresponding to the entities to retrieve. All * keys must be typed according to the generic type parameter of the entity's * {@link RawEntity} inheritence (if inheriting from {@link Entity}, this is <code>Integer</code> * or <code>int</code>). Thus, the <code>keys</code> array is type-checked at compile * time. * @return An array of entities of the given type corresponding with the specified * primary keys. Any entities which are non-existent will correspond to a <code>null</code> * value in the resulting array. */ public <T extends RawEntity<K>, K> T[] get(final Class<T> type, K... keys) throws SQLException { EntityInfo<T, K> entityInfo = resolveEntityInfo(type); final String primaryKeyField = entityInfo.getPrimaryKey().getName(); return get(type, findByPrimaryKey(type, primaryKeyField), keys); }