Hi there,

2014-05-15 12:05 GMT+02:00 cavemanjames <[email protected]>:

> Hey all,
>
> I'm not a very experienced Java programmer, even more so SQL. I just
> discovered jOOQ yesterday and I've already taken a liking to it.
>

Then, welcome! :-)


> But I've come across a couple of issues I can't figure out.
>
> I'm looking to implement multi-user logins but I don't really know how to
> go about doing it with jOOQ. Would I need to pass the username/password
> entered over to the xml configuration file?
>

You probably mean database logins? If by "xml configuration file" you mean
the config file for the code generator (as opposed to the settings.xml
file), then I suggest you use an admin user only to generate all your
schema objects. It's generally not a good idea to use a user with a reduced
set of GRANTs, as that will only generate parts of your schema. If you're
using MySQL, I would recommend generating the schema with the "root" user,
if you have access to that.

Once generated, the schema / table artefacts are pretty much independent of
the generating user.

The other thing I'm having trouble with is using left joins in jOOQ. I've
> read that section in the manual but for some reason I can't get it to work.
> Here's what I've got so far. The program keeps track of game matches for an
> upcoming local gaming tournament. The specific functionality I'm working on
> at the minute basically polls the database for all match info from a
> specific team and displays everything into a single table..
>
> create.select(Matches.MATCHES.MATCH_ID, Teams.TEAM.TEAM_NAME,
>> Match.MATCHES.MAP,
>>         //Get Registered Matches
>>         DSL.concat(String.valueOf(DSL.select(MatchLog.MATCH_LOG.GAME)
>>                 .where(MatchLog.MATCH_LOG.NEW_STATUS.equal("Registered")
>>
>> .and(MatchLog.MATCH_LOG.MATCH_ID.equal(Matches.MATCHES.MATCH_ID)))
>>
>> .orderBy(MatchLog.MATCH_LOG.GAME).limit(1))).as("match_registered"),
>>         //Get any Started Matches
>>         DSL.concat(String.valueOf(DSL.select(MatchLog.MATCH_LOG.GAME)
>>                 .where(MatchLog.MATCH_LOG.NEW_STATUS.equal("Started")
>>
>> .and(MatchLog.MATCH_LOG.MATCH_ID.equal(Matches.MATCHES.MATCH_ID)))
>>
>> .orderBy(MatchLog.MATCH_LOG.GAME).limit(1))).as("match_started"),
>>         //Get finished Matches
>>         DSL.concat(String.valueOf(DSL.select(MatchLog.MATCH_LOG.GAME)
>>                 .where(MatchLog.MATCH_LOG.NEW_STATUS.equal("Match Ended")
>>
>> .and(SMatchLog.MATCH_LOG.MATCH_ID.equal(Matches.MATCHES.MATCH_ID)))
>>
>> .orderBy(MatchLog.MATCH_LOG.GAME).limit(1))).as("match_finished"),
>>         //Obtain disputed Matches
>>         DSL.concat(String.valueOf(DSL.select(MatchLog.MATCH_LOG.GAME)
>>                 .where(MatchLog.MATCH_LOG.NEW_STATUS.equal("Report")
>>
>> .and(MatchLog.MATCH_LOG.MATCH_ID.equal(Matches.MATCHES.MATCH_ID)))
>>
>> .orderBy(MatchLog.MATCH_LOG.GAME).limit(1))).as("match_disputed")
>
>         );
>
> At the end of this, I want to put in these statements:
>
> "LEFT JOIN gamematches.team ON
>> gamematches.matches.team_id=gamematches.team.team_id\n"
>
> and...
>
>> "LEFT JOIN gamematches.players ON
>> gamematches.matches.player_id=gamematches.players.player_id\n"
>
> and finally...
>
>> "WHERE matches.team_id=?"
>
>
> But for some reason the .join() method just isn't showing up? Unless I
> need to place it somewhere else within the statement?
>

Aren't you missing a couple of FROM clauses in your main query and in your
subqueries? .join() and .leftOuterJoin() methods are available only on
Table types, and for convenience reasons, also on the SelectJoinStep type,
which is returned from the .from() method.


> Also, am I right in thinking that "DESC LIMIT 1" is the same as
> ".limit(1)"?
>

No, DESC ("descending") is part of your ORDER BY clause, as in "ORDER BY
[some column] DESC"

Cheers
Lukas

PS: It's generally a good idea to create a new topic per question on the
user group. That way, each question can be answered / tracked
independently, and it will be easier for future visitors to understand
what's going on...

-- 
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.

Reply via email to