public STelescope fetchByPK(Integer telescopeId) throws DAOException {
if (telescopeId == null) {
throw new TelescopeDAOException("telescopeId cannot be null");
}
STelescope telescope = null;
PreparedStatement statement = null;
ResultSet result;
Connection connection = DAOHelper.getDBConnection();
try {
try
{
statement = connection.prepareStatement(FETCHBYPK_QRY);
statement.setInt(1, telescopeId.intValue());
result = statement.executeQuery();
if(result.next())
{
telescope = new STelescope();
telescope.setObjId(result.getString("id"));
telescope.setObjClass(STelescope.class.getName());
telescope.setName(result.getString("name"));
telescope.setDescr(result.getString("description"));
if(result.next())
{
throw new TelescopeDAOException("Multiple rows exists for telescopeId " + telescopeId.toString());
}
}