/** * Read and return the next SqlRow. */ public SqlRow createNewRow(String dbTrueValue) throws SQLException { SqlRow sqlRow = new DefaultSqlRow(estimateCapacity, 0.75f, dbTrueValue); int index = 0; for (String propertyName : propertyNames) { index++; Object value = resultSet.getObject(index); sqlRow.set(propertyName, value); } return sqlRow; }
.map(row -> { ProjectsWithCostsGreaterThanOutput output = new ProjectsWithCostsGreaterThanOutput(); output.setProjectName(row.getString("project_name")); output.setTotalCost(row.getBigDecimal("total_cost")); output.setCompanyName(row.getString("company_name")); output.setCompanyCost(row.getBigDecimal("company_cost")); return output; })
@Override public synchronized List<AccountChest> getChests(GringottsAccount account) { // TODO ensure world interaction is done in sync task SqlQuery getChests = db.createSqlQuery("SELECT ac.world, ac.x, ac.y, ac.z " + "FROM gringotts_accountchest ac JOIN gringotts_account a ON ac.account = a.id " + "WHERE a.owner = :owner and a.type = :type"); getChests.setParameter("owner", account.owner.getId()); getChests.setParameter("type", account.owner.getType()); List<AccountChest> chests = new LinkedList<>(); for (SqlRow result : getChests.findSet()) { String worldName = result.getString("world"); int x = result.getInteger("x"); int y = result.getInteger("y"); int z = result.getInteger("z"); World world = Bukkit.getWorld(worldName); if (world == null) { continue; // skip chest if it is in non-existent world } Location loc = new Location(world, x, y, z); Block signBlock = loc.getBlock(); if (Util.isSignBlock(signBlock)) { Sign sign = (Sign) loc.getBlock().getState(); chests.add(new AccountChest(sign, account)); } else { // remove accountchest from storage if it is not a valid chest deleteAccountChest(worldName, x, y, z); } } return chests; }
Object keyValue = bean.get(mapKey); wrapper.addToMap(bean, keyValue); } else {
@Override public RegisterEmployeeOutput callRegisterEmployee(String name, String surname, String email, BigDecimal salary, String departmentName, String companyName) { String query = "SELECT employee_id, department_id, company_id FROM register_employee(:name, :surname, :email, :salary, :departmentName, :companyName)"; SqlRow row = ebean.createSqlQuery(query) .setParameter("name", name) .setParameter("surname", surname) .setParameter("email", email) .setParameter("salary", salary) .setParameter("departmentName", departmentName) .setParameter("companyName", companyName) .findUnique(); RegisterEmployeeOutput result = new RegisterEmployeeOutput(); result.setEmployeePid(row.getInteger("employee_id")); result.setDepartmentPid(row.getInteger("department_id")); result.setCompanyPid(row.getInteger("company_id")); // this is required so the EBean caches are invalidated Ebean.externalModification("department", true, false, false); Ebean.externalModification("company", true, false, false); Ebean.externalModification("employee", true, false, false); return result; }
String worldName = c.getString("world"); int x = c.getInteger("x"); int y = c.getInteger("y"); int z = c.getInteger("z"); String type = c.getString("type"); String ownerId = c.getString("owner");
Object keyValue = bean.get(mapKey); wrapper.addToMap(bean, keyValue); } else {
/** * Read the row from the ResultSet and return as a MapBean. */ protected SqlRow readRow(RelationalQueryRequest request, ResultSet rset, String[] propNames, int initialCapacity) throws SQLException { // by default a map will rehash on the 12th entry // it will be pretty common to have 12 or more entries so // to reduce rehashing I am trying to estimate a good // initial capacity for the MapBean to use. SqlRow bean = new DefaultSqlRow(initialCapacity, 0.75f, dbTrueValue); int index = 0; for (int i = 0; i < propNames.length; i++) { index++; Object value = rset.getObject(index); bean.set(propNames[i], value); } return bean; }
/** * Read the row from the ResultSet and return as a MapBean. */ protected SqlRow readRow(RelationalQueryRequest request, ResultSet rset, String[] propNames, int initialCapacity) throws SQLException { // by default a map will rehash on the 12th entry // it will be pretty common to have 12 or more entries so // to reduce rehashing I am trying to estimate a good // initial capacity for the MapBean to use. SqlRow bean = new DefaultSqlRow(initialCapacity, 0.75f, dbTrueValue); int index = 0; for (int i = 0; i < propNames.length; i++) { index++; Object value = rset.getObject(index); bean.set(propNames[i], value); } return bean; }