My initial questions/comments as a new JOOQ user

292 views
Skip to first unread message

elect...@gmail.com

unread,
Oct 14, 2013, 6:03:19 PM10/14/13
to jooq...@googlegroups.com
So, I finally decided to give JOOQ a real try!

I'll use this thread to ask my (probably newbie) questions and post my comments.

I plan on following the manual ( http://www.jooq.org/doc/3.2/manual-single-page/ ), at least for a while.

I currently use PostgreSQL 9.1, on a Windows 7 machine. I use JOOQ 3.2.0 with the jooq-codegen-maven plugin and with PostgreSQL's 9.1-901.jdbc4 driver.


My first comments/questions :

- The sample database schema : http://www.jooq.org/doc/3.2/manual-single-page/#sample-database doesn't work directly with PostgreSQL. I know you probably can't provide a schema that is compatible with all databases, but I'm just saying... It doesn't feel nice to start with those errors when starting... Don't forget that the manual (Which seems otherwise very nice!) is often the first real contact a developer will have with JOOQ!
To make it work, I replaced :
  1. "NUMBER" by "NUMERIC" (except "NUMBER(1)" by "BOOLEAN" or otherwise the code generator would use Byte as the type of the field instead of Boolean)
  2. "VARCHAR2" by "VARCHAR"
  3. Add semi-colons after each statement

- It would be nice to provide some queries to populate this sample database with initial data. The code examples you give in the manual don't look impressive when they return nothing at all.

- In the CRUD example, http://www.jooq.org/doc/3.2/manual-single-page/#jooq-for-crud , FK_BOOK_AUTHOR is used but I don't have this constant generated. I think it should be BOOK__FK_BOOK_AUTHOR ?

Thanks!

Lukas Eder

unread,
Oct 15, 2013, 4:04:08 AM10/15/13
to jooq...@googlegroups.com
Hello and thanks for the feedback.


2013/10/15 <elect...@gmail.com>

So, I finally decided to give JOOQ a real try!

I'll use this thread to ask my (probably newbie) questions and post my comments.

I plan on following the manual ( http://www.jooq.org/doc/3.2/manual-single-page/ ), at least for a while.

I currently use PostgreSQL 9.1, on a Windows 7 machine. I use JOOQ 3.2.0 with the jooq-codegen-maven plugin and with PostgreSQL's 9.1-901.jdbc4 driver.


My first comments/questions :

- The sample database schema : http://www.jooq.org/doc/3.2/manual-single-page/#sample-database doesn't work directly with PostgreSQL. I know you probably can't provide a schema that is compatible with all databases, but I'm just saying... It doesn't feel nice to start with those errors when starting... Don't forget that the manual (Which seems otherwise very nice!) is often the first real contact a developer will have with JOOQ!
To make it work, I replaced :
  1. "NUMBER" by "NUMERIC" (except "NUMBER(1)" by "BOOLEAN" or otherwise the code generator would use Byte as the type of the field instead of Boolean)
  2. "VARCHAR2" by "VARCHAR"
  3. Add semi-colons after each statement

- It would be nice to provide some queries to populate this sample database with initial data. The code examples you give in the manual don't look impressive when they return nothing at all.

Yes, it might be good to provide a link to a working sample SQL script for each supported database. Or better, I would finally make the integration-tests work with Maven and publish links to those tests (and the contained SQL scripts) from the manual. This has been on the roadmap for a while: https://github.com/jOOQ/jOOQ/issues/682
 
- In the CRUD example, http://www.jooq.org/doc/3.2/manual-single-page/#jooq-for-crud , FK_BOOK_AUTHOR is used but I don't have this constant generated. I think it should be BOOK__FK_BOOK_AUTHOR ?

Only the PostgreSQL generator generates key literals like this, because the key namespace is defined per table, not per schema in PostgreSQL.

Cheers
Lukas

Rakesh Waghela

unread,
Oct 22, 2013, 5:58:51 AM10/22/13
to jooq...@googlegroups.com
If anyone is interested in having a schema which is supported in some of the most common databases along with populated data, then I have a suggestion to make,

http://chinookdatabase.codeplex.com/

Above Schema is supported for following servers,


Enjoy the JOOQ Generator Experience on all these database with consistent schema, for getting your hands dirty :)

Lukas Eder

unread,
Oct 23, 2013, 4:01:36 AM10/23/13
to jooq...@googlegroups.com
Hi Rakesh,

EffiProz! Whatever that database is :-)

This looks like a nice sample schema with an acceptable license (I think). I might even contribute other database integrations to the authors. I have registered this as a feature request: #2794

Cheers
Lukas


2013/10/22 Rakesh Waghela <java...@gmail.com>
--
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 jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

elect...@gmail.com

unread,
Nov 3, 2013, 3:01:49 PM11/3/13
to jooq...@googlegroups.com
I have another question :

For my framework, let's say the application developer needs to specify the type of database he uses. For example with the string "h2" or "postgres".

What is the easiest way to get the associated "Database" (a class extending org.jooq.util.AbstractDatabase) from this string? I need to get "org.jooq.util.h2.H2Database" or "org.jooq.util.postgres.PostgresDatabase" for example. Is there an utility method for that?

I already get the associated org.jooq.SQLDialect from the "h2" or "postgres" string (by checking the enum names), but I also need the associated Database class. Do I have to implement my own switch structure or is there already an utility method for that?

Thanks in advance!




Lukas Eder

unread,
Nov 3, 2013, 5:17:51 PM11/3/13
to jooq...@googlegroups.com
Hello,

2013/11/3 <elect...@gmail.com>
There is JDBCUtils.dialect(...), which helps you guess a SQLDialect given a Connection, or a connection URL:


jOOQ currently does not help you go from the SQLDialect to the relevant org.jooq.util.Database. I have registered #2828 to add support for this in jOOQ 3.3:

Cheers
Lukas

electrotype

unread,
Nov 3, 2013, 5:24:58 PM11/3/13
to jooq...@googlegroups.com
As always, you're very fast to reply, thanks!

So I'll implement my own switch structure for now.

Regards,

electrotype
--
You received this message because you are subscribed to a topic in the Google Groups "jOOQ User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jooq-user/wxNnSm5GGW0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+...@googlegroups.com.

elect...@gmail.com

unread,
Nov 5, 2013, 3:33:45 PM11/5/13
to jooq...@googlegroups.com
Hi Lukas,

I use :

------------------------
<pojos>true</pojos>
<interfaces>true</interfaces>
<daos>true</daos>

------------------------

I see that the generated DAOs use the pojos implementations as the types they deal with, instead of the associated interfaces.

For example, this is generated :

userDao#update(User);

not

userDao#update(IUser);


So if I play with IUser implementing objects and I want to use their associated DAOs, I have to convert them to User first by myself, right? Is there a reason for that?

Since the User pojo already contains a from(IUser) method, I guess Jooq could do the convertion by itself?

Thanks in advance!


elect...@gmail.com

unread,
Nov 6, 2013, 11:36:03 AM11/6/13
to jooq...@googlegroups.com
Another question with DAOs :

What is the recommended workaround for bug https://github.com/jOOQ/jOOQ/issues/2700 ?

DAOs are currently not usable if there is a default value columns. This is pretty much a show stopper for me (at least for DAO use)...

Thanks.

Lukas Eder

unread,
Jan 7, 2014, 8:12:46 AM1/7/14
to jooq...@googlegroups.com
#2828 is now implemented for jOOQ 3.3. The "Database" name can thus be omitted, as the default jOOQ-Meta Database implementation will be inferred from the JDBC URL through JDBCUtils.dialect(url). Obviously, this may not always work, depending on your URL, which may not be unambiguous.

Cheers
Lukas


2013/11/3 Lukas Eder <lukas...@gmail.com>
Reply all
Reply to author
Forward
0 new messages