Hello Dominic,
2013/11/8 <[email protected]> > Hi, just trying out COOQ [...] > Yes, I'm sure the C guys would prefer jOOQ over Pro*C as well ;-) > [...] and thinking would be nice to only partially load generated records > in some cases, for example when only a small number of fields in a wide > table will be used. > > 1. Cannot see how to do this as we are forced to use .selectFrom() and > select() is unavailable e.g. how to modify below? > > DSLContext create = DSL.using(DB.getConnection(), SQLDialect.MARIADB > ); > > List<PostalCodeRecord> postalCodes = create.fetch(POSTAL_CODE); > > 2. If partial loading is possible, is it also possible to implement lazy > loading on those not loaded initially? > The above is possible, but unfortunately not in the way you might like to see. With jOOQ 3.x's introduction of Record[N] types, the select() clause re-defines the resulting Record type to be a tuple. From an API and language perspective, it wouldn't make sense to re-define this row type in the subsequent from() clause. selectFrom() is a bit special (and historical). There's currently no "sensible" way to restrict the projection of a "selectFrom()" query. What you can do is use this: Result<PostalCodeRecord> select(POSTAL_CODE.ID) .from(POSTAL_CODE) .fetch() .into(POSTAL_CODE); You can then "lazy-load" the remaining fields from this record using postalCode.refresh(POSTAL_CODE.FIELD1, POSTAL_CODE.FIELD2); See also: - http://www.jooq.org/javadoc/latest/org/jooq/Result.html#into(org.jooq.Table) - http://www.jooq.org/javadoc/latest/org/jooq/UpdatableRecord.html#refresh(org.jooq.Field...) Hope this helps Lukas -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
