public Object map(ResolvedMethod method, Query q, HandleDing h) { if (method.getRawMember().isAnnotationPresent(Mapper.class)) { final ResultSetMapper mapper; try { mapper = method.getRawMember().getAnnotation(Mapper.class).value().newInstance(); } catch (Exception e) { throw new UnableToCreateStatementException("unable to access mapper", e); } return result(q.map(mapper), h); } else { return result(q.mapTo(mapTo(method)), h); } }
public Object map(ResolvedMethod method, Query q, HandleDing h) { if (method.getRawMember().isAnnotationPresent(Mapper.class)) { final ResultSetMapper mapper; try { mapper = method.getRawMember().getAnnotation(Mapper.class).value().newInstance(); } catch (Exception e) { throw new UnableToCreateStatementException("unable to access mapper", e); } return result(q.map(mapper), h); } else { return result(q.mapTo(mapTo(method)), h); } }
@SqlQuery("SELECT p.id, p.name, p.price, b.id AS baseId, b.name AS baseName, t.id AS toppingId, t.name AS toppingName FROM pizza p INNER JOIN base b ON (b.id = p.base_id) INNER JOIN pizza_toppings pt ON (pt.pizza_id = p.id) INNER JOIN topping t ON (t.id = pt.toppings_id) ORDER BY p.id ASC") @Mapper(PizzaMapper.class) List<Pizza> findOrderByIdAsc();
@Mapper(MessageMapper.class) @SqlQuery("SELECT * FROM messages WHERE " + DESTINATION + " = :destination AND " + DESTINATION_DEVICE + " = :destination_device ORDER BY " + TIMESTAMP + " ASC LIMIT " + RESULT_SET_CHUNK_SIZE) abstract List<OutgoingMessageEntity> load(@Bind("destination") String destination, @Bind("destination_device") long destinationDevice);
@SqlQuery("SELECT n.node_identifier, x.bytes\n" + "FROM (\n" + " SELECT node_id, sum(compressed_size) bytes\n" + " FROM (\n" + " SELECT sn.node_id, s.compressed_size\n" + " FROM shards s\n" + " JOIN shard_nodes sn ON (s.shard_id = sn.shard_id)\n" + " WHERE s.bucket_number IS NULL\n" + " UNION ALL\n" + " SELECT b.node_id, s.compressed_size\n" + " FROM shards s\n" + " JOIN tables t ON (s.table_id = t.table_id)\n" + " JOIN distributions d ON (t.distribution_id = d.distribution_id)\n" + " JOIN buckets b ON (\n" + " d.distribution_id = b.distribution_id AND\n" + " s.bucket_number = b.bucket_number)\n" + " ) x\n" + " GROUP BY node_id\n" + ") x\n" + "JOIN nodes n ON (x.node_id = n.node_id)") @Mapper(NodeSize.Mapper.class) Set<NodeSize> getNodeSizes();
@SqlQuery("SELECT n.node_identifier, x.bytes\n" + "FROM (\n" + " SELECT node_id, sum(compressed_size) bytes\n" + " FROM (\n" + " SELECT sn.node_id, s.compressed_size\n" + " FROM shards s\n" + " JOIN shard_nodes sn ON (s.shard_id = sn.shard_id)\n" + " WHERE s.bucket_number IS NULL\n" + " UNION ALL\n" + " SELECT b.node_id, s.compressed_size\n" + " FROM shards s\n" + " JOIN tables t ON (s.table_id = t.table_id)\n" + " JOIN distributions d ON (t.distribution_id = d.distribution_id)\n" + " JOIN buckets b ON (\n" + " d.distribution_id = b.distribution_id AND\n" + " s.bucket_number = b.bucket_number)\n" + " ) x\n" + " GROUP BY node_id\n" + ") x\n" + "JOIN nodes n ON (x.node_id = n.node_id)") @Mapper(NodeSize.Mapper.class) Set<NodeSize> getNodeSizes();