Package org.jooq

Examples of org.jooq.Record


        return records;
    }

    @Override
    public final RecordType<?> recordType() {
        Record record = record();
        return record != null ? new Fields<Record>(record.fields()) : null;
    }
View Full Code Here


        .setSourceNameTokenizer(NameTokenizers.UNDERSCORE)
        .addValueReader(new RecordValueReader());
  }

  public void shouldMapFromRecord() throws Exception {
    Record record = ctx.fetch("select * from orders").get(0);

    Order order = modelMapper.map(record, Order.class);

    assertEquals(order.id, 456);
    assertEquals(order.customer.id, 789);
View Full Code Here

    assertEquals(order.customer.address.city, "SF");
    assertEquals(order.customer.address.zip, null);
  }

  public void shouldMapWithExplicitMapping() throws Exception {
    Record record = ctx.fetch("select * from orders").get(0);

    modelMapper.createTypeMap(record, Order.class).addMappings(new PropertyMap<Record, Order>() {
      @Override
      protected void configure() {
        map(source("customer_street_address")).getCustomer().getAddress().setStreet(null);
View Full Code Here

        UniqueKey<R> key = table.getPrimaryKey();
        if (key == null)
            return null;

        TableField<R, Object>[] fields = (TableField<R, Object>[]) key.getFieldsArray();
        Record result = DSL.using(configuration)
                           .newRecord(fields);

        for (int i = 0; i < values.length; i++) {
            result.setValue(fields[i], fields[i].getDataType().convert(values[i]));
        }

        return (T) result;
    }
View Full Code Here

                }

                // [#3023] Record types can be converted using the supplied Configuration's
                // RecordMapperProvider
                else if (Record.class.isAssignableFrom(fromClass)) {
                    Record record = (Record) from;
                    return record.into(toClass);
                }

                /* [pro] xx
                xx xxxxxxx xxxxxx xxxxxx x xxxxx xxxxx xxxxxx xx xxxxxxxxxxx xxxx xxxxxx xxx xxxxxxxxxxx
                xxxx xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x
View Full Code Here

                    @Override
                    public BindingSet next() throws QueryEvaluationException {
                        if(splitBindings != null) {
                            return splitBindings.next();
                        } else {
                            Record record = cursor.fetchOne();

                            // check if the result contains multiple SPARQL bindings in a single row or
                            // only one SPARQL row; we can do this by checking whether the first result starts
                            // with _multi
                            if(record.getField(0).getName().startsWith("_multi")) {
                                log.info("transforming single-row SQL result into multi-row SPARQL result");
                                List<BindingSet> results = new ArrayList<BindingSet>();
                                for(int i=1; true; i++) {
                                    MapBindingSet result = new MapBindingSet();
                                    for(String var : mapper.getProjectedVariables()) {
                                        if(var.startsWith("_multi") && var.endsWith("_"+i)) {
                                            Long nodeId = record.getValue(var, Long.class);

                                            if(nodeId != null) {
                                                Value value = em.find(KiWiNode.class, nodeId);

                                                result.addBinding(var.substring(var.indexOf('_',1)+1,var.lastIndexOf('_')),value);
                                            }
                                        }
                                    }
                                    for(Map.Entry<String,Class> ext : mapper.getExtensionVariables().entrySet()) {
                                        String var = ext.getKey();
                                        if(var.startsWith("_multi") && var.endsWith("_"+i)) {
                                            Object val = record.getValue(ext.getKey(),ext.getValue());

                                            // this is truly a hack: we check whether the string is a URI, and if yes create a URI resource...
                                            // it would be better to carry over this information from the value constants
                                            if(urlValidator.isValid(val.toString())) {
                                                URI value = new URIImpl(val.toString());
                                                result.addBinding(var.substring(var.indexOf('_',1)+1,var.lastIndexOf('_')),value);
                                            } else {
                                                String type = LiteralCommons.getXSDType(ext.getValue());

                                                // we only create an in-memory representation of the value, the LMF methods
                                                // would automatically persist it, so we create a Sesame value
                                                Value value = new LiteralImpl(val.toString(),sesameService.getValueFactory().createURI(type));
                                                result.addBinding(var.substring(var.indexOf('_',1)+1,var.lastIndexOf('_')),value);
                                            }
                                        }
                                    }
                                    if(result.size() == 0) {
                                        break;
                                    } else {
                                        results.add(result);
                                    }
                                }
                                em.clear();
                                splitBindings = results.iterator();
                                return splitBindings.next();
                            } else {

                                MapBindingSet result = new MapBindingSet();
                                for(String var : mapper.getProjectedVariables()) {
                                    Long nodeId = record.getValue(var, Long.class);

                                    if(nodeId != null) {
                                        Value value = em.find(KiWiNode.class, nodeId);
                                        result.addBinding(var,value);
                                    }
                                }
                                for(Map.Entry<String,Class> ext : mapper.getExtensionVariables().entrySet()) {
                                    Object val = record.getValue(ext.getKey(),ext.getValue());

                                    // this is truly a hack: we check whether the string is a URI, and if yes create a URI resource...
                                    // it would be better to carry over this information from the value constants
                                    if(urlValidator.isValid(val.toString())) {
                                        URI value = new URIImpl(val.toString());
View Full Code Here

        }

        @Override
        public void run(int input)
        {
            Record r = q.bind(1, input).fetchOne();
            Post p2 = r.into(Post.class); // TODO this fails for some unknown reason
        }
View Full Code Here

TOP

Related Classes of org.jooq.Record

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.