(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| package helpers; | |
| import org.jooq.DSLContext; | |
| import java.util.Collection; | |
| /** | |
| * | |
| */ | |
| public class DSLWrapper { |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| public class EZMap<T> { | |
| public static void main(String[] args) { | |
| Map<String,Object> m = hashMap( | |
| bob -> 5, | |
| TheGimp -> 8, | |
| incredibleKoolAid -> "James Taylor", | |
| heyArnold -> new Date() | |
| ); | |
| System.out.println(m); | |
| } |
| @Table(name="FOO") | |
| public class Bar{ | |
| @Column(name="MY_CUSTOM_NAME") | |
| private String name; | |
| } | |
| /* | |
| Table structure : | |
| -------------------- | |
| | FOO | |
| object vals { | |
| val fn: Int => String = (n) => n.toString | |
| val f = fn _ // works because fn is a method | |
| def method = { | |
| val fn: Int => String = (n) => n.toString | |
| val f = fn _ // doesn't work because fn is not a method | |
| } | |
| } |
Demonstration of using SBT to invoke jOOQ-codegen
The "jooq-codegen" task generates sources under "src/main/jooq" (which is added as a Java source directory). I put them here instead of "src/main/java" because the directory must be emptied before generation, so I don't want to chance emptying a directory that might contain other sources.
I check the jOOQ-generated code into version control. This makes it easier to work away from the office where I don't have easy access to the database. It also gives me a better picture of database changes, because they are reflected as commits.
| apply from: "${rootDir}/gradle/java.gradle" | |
| dependencies { | |
| compile libraries.guava | |
| compile libraries.guice | |
| compile libraries.jooq | |
| } | |
| buildscript { | |
| repositories { |
| package com.jthompson; | |
| import java.io.File; | |
| import java.sql.Connection; | |
| import java.sql.ResultSet; | |
| import lombok.extern.java.Log; | |
| import org.jooq.tools.jdbc.MockConnection; | |
| import org.jooq.tools.jdbc.MockDataProvider; |