Hi Ankur, Thanks for the clarification.
There are lots of models of how people like to model their data transfer objects. jOOQ only provides some basic mapping algorithms that we have found to be very common over the years. But we refrain from saying anything like: You should use POJOs. Or you should use HashMaps. Or you should use jOOQ's UpdatableRecords... In my personal opinion (not really a jOOQ recommendation), I really like to keep all things "relational" (or at least SQL-esque) throughout the application. I like jOOQ's Record types, and if possible UpdatableRecords, because they can be stored back to the database with optimistic locking and all the other features. A Record is a very convenient value-type representation of the data produced by your query. A Record can be easily transformed: - Using jOOQ's various Result / Record methods - Using Java 8 Streams if you're working with that (examples in here: http://blog.jooq.org/2014/04/11/java-8-friday-no-more-need-for-orms/) - Using XSLT if you're using XML, and jOOQ's Result.formatXML() - Using JavaScript if you're exporting records to your browser using Result.formatJSON() But that's me. I like functional and declarative languages much more than OO domain models. As you can see, this will easily evolve into an endless discussion :) There's no right or wrong in these design decisions. jOOQ should support all of them through the most generic API possible. Which also means that jOOQ might not help you make the best decision for *your* application. Cheers, Lukas 2014-07-01 10:26 GMT+02:00 ankur bhargava <[email protected]>: > Hi Lukas, > > My questions was, what should be the approach when we are creating query > which would have JOIN operations and in result it is selecting different > columns from different tables then how would store result in JAVA POJO > class? Do we need to create new java pojo class which would contain all > properties's for resultant columns? Or can we store results into in any > Collection ? > > I am going through the links and will update you if these links would > answer my question. > > Thanks, > Ankur > > > > > On Tuesday, July 1, 2014 1:02:36 PM UTC+5:30, Lukas Eder wrote: > >> Hello Ankur, >> >> I'm not quite sure what exactly you're asking here. The "into(Class)" >> operation is completely independent of what you queried before in your jOOQ >> SQL statement. By default, it follows the algorithm specification defined >> in DefaultRecordMapper: >> http://www.jooq.org/javadoc/latest/org/jooq/impl/DefaultRecordMapper.html >> >> That algorithm can be overridden by implementing a custom >> RecordMapperProvider: >> http://www.jooq.org/doc/latest/manual/sql-execution/fetching/pojos-with- >> recordmapper-provider/ >> >> In order to fetch into HashMaps, there are a couple of relevant fetch >> methods as well (the list in the manual is non-exhaustive): >> http://www.jooq.org/doc/latest/manual/sql-execution/ >> fetching/arrays-maps-and-lists/ >> >> Let me know if this answers your question(s). >> Lukas >> >> 2014-06-30 15:06 GMT+02:00 ankur bhargava <[email protected]>: >> >>> this might be silly but just to seek confirmation, >>> >>> I have a situation when I am querying one db table and I want fetched >>> records map to XyzRecord.java this we can achieve easily but what should be >>> done when query is resulting multiple columns from multiple tables and >>> we want to map it to a JAVA POJO kind of class. And we want it to store >>> fetched records in List<POJO> collection Or in any collection like HashMap. >>> >>> *DSLContext jOOQDslCtx = getJooqDslCtx(getDBConnection("mytestdb")); * >>> * List<AuthorRecord> authList = >>> jOOQDslCtx.select().from(Author.AUTHOR).fetchInto(AuthorRecord.class); * >>> >>> above code is working fine and I want to achieve the same in case of >>> when query fetches columns from multiple tables. >>> >>> Please advice! >>> Ankur >>> >>> >>> >>> -- >>> 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/d/optout. >>> >> >> -- > 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/d/optout. > -- 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/d/optout.
