« first day (1604 days earlier)      last day (3341 days later) » 

5:00 PM
It's classes with logic in them I don't know what they'll be exactly yet, which is probably where my design is a bit borked as well. The logic the services use?
 
@Gemtastic Well, why not do the logic in the service?
 
Sometimes the logic will be too big to fit in a service, I assume
 
@Gemtastic Like what?
 
I don't know yet
 
Alright
What's Connection?
 
5:02 PM
Atm it's just any class that isn't a model object or a service
Connection is the class responsible for connecting to the database. JooQ needs it but it's something I configure, not jooq
 
@Gemtastic Services don't have direct access to the database
(Or any form of storage, for that matter)
Services depend on data mapper objects to carry out all storage mapping
 
Well, that's something I misunder stood then
Not that the servises in my model has direct access to the db either
 
Have I understood this correctly,
 
I thought that was Connection?
 
They connect to the models jooq has generated, which in turn through jooq have a connection to the db
Connection only hlod the connection
You need it whenever you are gonna query the db
So what does have a direct connection to the db? what's that layer called?
 
5:06 PM
Data Mapper
Here's an example for an AuthenticationService::doLogin method
 
catch (Exception e)
{
system.out.println (e,getClass());
}

will do the job of multiple
catch (whatever exception here e)
system.out.println (e)

etc

Thanks
^^is that correct?
Thanks
 
@mikeeustace why is there a coma there?
 
typo
 
Ah, ok
@SecondRikudo But they are inside of JooQ
Do I make a class for each mapping I need to do then create POJO to map it to?
 
so,can I use

catch (Exception e)
{
System.out.println (e.getClass());
}

instead of


}
catch(FileNotFoundException e) {
System.out.println(e);
}
catch(IOException e) {
System.out.println(e);
}


Thanks
 
5:11 PM
class AuthenticationService implements Service {
    public AuthenticationService(UserMapper dbMapper, UserMapper sessionMapper) {}

    public boolean doLogin(String username, String password) {
        User user = dbMapper.byUsername(username);
        boolean result = passwordVerify(password, user.getHashedPassword());
        if (result) { sessionMapper.store(user); }
        return result;
    }

}
User can be a class generated by JooQ. UserMapper should be your own interface.
See how the service doesn't know where dbMapper gets its information, in fact, the only thing that indicates it even comes from the database is the name.
The controller calls authService.doLogin(form.username, form.password)
passwordVerify is a private method on AuthenticationService that handles verification against a hashed password
Of course, your service can call your other classes (the ones you named Logic Classes), if it needs help in doing things like crypto.
Or you can keep it simple for the assignment (don't) and not hash (don't), in which case passwordVerify is a simple expected.equals(existing) (don't).
 
But something I don't quite get is that I'm supposed to make a bunch of interfaces but I've never heard about the objects which implements it...
UserMapper, who implements that? (classes are a who now)
 
@Gemtastic Here's what the UserMapper interface could look like
public interface UserMapper extends Mapper {
    public User byUsername(String username);
}

public interface Mapper {
    public Object get(Object input);
    public void map(Object input);
}
 
But who implements it?
 
As for who implements it, concreete implementations can be public class UsemrDatabaseMapper implements UserMapper, public class UserSessionMapper implements UserMapper
In the future, maybe UserRestMapper and UserNullMapper or even UserRandomMapper just for giggles.
Mapper abstracts the storage from the layer above it.
It hides the storage details from the consuming service.
In short, your service shouldn't know you're using JooQ.
 
So any class that somehow needs to map something with the user?
In my case, the user is an employee
 
5:19 PM
Right, that "something" is data from the database, in this case.
 
I've never done any log ins before :/
 
dbMapper.store(userObject);
 
Wait, the interface is so the mapper maps to the database?
 
When you call this, the mapper will invoke JooQ to update/create the user as described in the object.
@Gemtastic To and from
Data mappers always go both ways.
 
I could reeeaaally use a finished project to learn from :/
 
5:20 PM
They map data to/from the data source
 
@SecondRikudo Ok, then I'm not confused any more
On that part... sigh
What are my lego pieces here...
I'm trying to identify them...
 
The rest of your drawing looks fine to me.
And I know data mapper is a tricky layer to grasp
 
ok, so I'm not completely lost on the big picture.
The issue here is that I don't know what JooQ does yes, other than some magic involving the objects and the tables
So I don't know where the mappers fit
Are they inside of Jooq?
Is it something I have to make?
Do I make it with Jooq?
 
@Gemtastic whatever JooQ does, you can always abstract it away behind your own layer of POJOs and mappers
But that's the worst possible scenario, you most likely can integrate JooQ nicely here.
My guess is that JooQ acts as both here (in creating your POJOs for you, and in mapping to them)
In which case, all you need to do is add a thin Facade to maintain a reasonable interface
 
At this point, I just want to see the code for taking an input from the view on what customer to return to the view, the process in retrieving the customer from the database and put it into the view
 
5:25 PM
(which even that may be provided by JooQ)
 
To me, I'm thinking that the result of a query also needs to be a POJO
Let's say I want the statistics for how often customer X came to the shop to use its services last year
 
@Gemtastic the result of a query is always (at least conceptually), until it gets processed, a Map<int, Map<int, Object>>
 
A map map!
 
First int is the row number, and second is the column number
Inner map can also be String, Object
 
Also, thank you! I've been wondering what Java sees the result set as
 
5:27 PM
(String for column name)
It's often also expressed as a stream of inner maps
(where each element in the stream is a row)
 
You can coose if you want the name or number of the column?
 
I think jdbc allows you to do it
Not sure how it's done in Java TBH
 
fge
With JooQ you won't be doing that
 
Yeah, this is on a much lower level than JooQ ^
 
fge
While it is conceptually true, it's the most horrible model you can adopt
 
5:29 PM
Well, you're the one saying it could also be a string, so I assumed the second int was the column number, and then string would be the name
 
@Gemtastic Yes, that's correct.
It's worth noting that I'm talking about the raw mysql result here
No processing done by anyone yet (JooQ, hibernate, your own code)
 
Syntax being Map<rownumber, map<coulmnnumber, object>>
@SecondRikudo That's what I wondered about
I feel like I need to know that to better understand what j00q gives me
Because jooq does something with that result set
 
JooQ will, among other things, take that result, and map it to the POJOs it created based on your schema.
 
And I get that something.
 
(And @fge please correct me if I'm wrong, I'm making educated guesses here)
 
5:32 PM
So in other words, I won't be doing any mapping?
I just orchestrate jooq to map it for me?
 
fge
Yes
 
It's entirely possible that all your Mapper layer would be doing is to delegate to JooQ, yes.
 
fge
By default JooQ will return a Record
And the Record is typesafe up to 22 columns
Row22<T1, T2, ...., T22>
Err
Record22
However, if you use the records generated for you you may directly get, for instance, a (list of) CarRecord, or you can use a CarRecord for CRUD too
All of this is extensively documented
 
@fge 22? XD And if you have more columns than that?
@fge Wait, you can call carRecord.get() and stuff?
 
fge
Well, it's a stragith Record and you'll have to .getField(theFieldNumber, SupposedClass.class)
Again, that's documented
Personally I never used that, but the JooQ manual will tell you what you can do (and that is many things)
 
5:36 PM
@fge Because that sounds like abstraction leak to me :P
Alright, boiler running for a while now, Imma take a shower, then we can voice chat @Gemtastic?
 
fge
Just go read the docs :p
 
@fge linkiez?
 
fge
jooq.org/doc/3.5/manual <-- everything is there
 
@fge Gotta love 1MB manuals :D
 
@SecondRikudo Yes we can :)
 
5:53 PM
Alright. @fge have you gotten over your mic crisis?
 
I've been wondering what a record is... It's just a bean, isn't it?
 
@Gemtastic Yeah, it's an object that represent a resultset. Usually, it holds a cursor to the results, which you can advance, rewind or set
like
 
fge
Not with JooQ, no
You should really read the manual ;)
 
int sum = 0;
while (record.next() != null) {
    sum += record.getInt("some_number_column");;
}
return sum;
 
@fge dude, doesnt fetch one only return one record?
I get this error, (googled it BTW): org.jooq.exception.InvalidResultException: Cursor returned more than one result
 
5:57 PM
I'm in the middle of it. I don't like the jooq manual. I feel like it's written for someone who already understands it :/
 
fge
@LeeJeong no, of course not
 
@Gemtastic well it's hard not to write that way if you already know stuff..
 
fge
You used .fetchOne()?
 
when using fetchOne, i assume whatever the query was, and howver many the records would return it would just return the top most 1.
yeah, i used, fetchOne
 
fge
No, of course not
 
5:57 PM
when do you really use it?
 
fge
You ask EXPLICITLY to fetch one
If not --> boom
 
@Vogel612 If you can't explain it to a 5 year old, you don't understand it well enough.
 
Not to mention I've already gotten to the point where they show the record in the code but do not explain what it is
 
fge
That's logical
 
@SecondRikudo meh.
That doesn't make the majority of manuals easier to read.
 
5:58 PM
@fge if not only one in the database exist --> boom?
 
@Vogel612 No, I feel like it's written FOR people who already understands it. Not BY someone who already understands it. The later is a given.
 
fge
Yes, or if zero exist
 
@Vogel612 That's because the majority of manuals are written with presumptions in mind.
 
Kinda like the Spring tutorials... "When you've learned how to do this, the tutorials will make sense. Until then, enjoy your frustration ride!"
 
@LeeJeong Well, fetchOne is kinda self explanatory. It can only fetch one.
 
fge
5:59 PM
@Gemtastic look here for instance: jooq.org/doc/3.5/manual/sql-execution/fetching/pojos
 
so, i have to add like LIMIT 1 on my query correct?
 
!!xkcd manuals
 
@SecondRikudo your also expert on JOOQ?
 
posted on March 15, 2015 by Artist

How I feel working on this project: But hey, I made a log in window so I've got that thing going for me which is nice...

 
6:00 PM
@fge in response to section 3.1 of JooQ's manual ^^
 
fge
@LeeJeong if what you want is indeed only the first element then yes
 
@LeeJeong Nope.
 
oh fuck... good catch, that I have about 40 instances of fetchOne right now, all over my application.. fvck. Really bad to assume.
 
fge
That is quite different than having a result which you know will return a single element; you still make the engine retrieve all the set, .limit() only applies AFTER
 
@LeeJeong Either that or make sure that your query only returns one row (for example, by querying for equality on a UNIQUE or PRIMARY KEY field)
 
6:02 PM
I don't really expect things to be pedagogic, I just want them to make sense.
 
RIGHT! thanks @fge and @SecondRikudo, now i know where I can ask when @fge is not around.
 
If there's a chance your query can return more than one row, you don't want fetchOne
@LeeJeong I only employ my common sense.
I've never used JooQ in my life
But you can try :D
@fge Care for a session that creates a simple schema, runs the JooQ code generator, and then does stuff with an object (just a Hello World example)?
 
wow! that's more amazing @SecondRikudo .. I guess i would get that sense too over time of drowning in code dev
 
I feel like that could close @Gemtastic's loop a lot better.
 
fge
@SecondRikudo not now, sorry, I'm eyeballs deep in grammar writing
 
6:04 PM
kk
 
fge
I need to sort something which is bugging me otherwise I can't calm down :p
 
Take care of it then and I'll keep trying to read this manual.
And I mean try because it makes no sense to me
 
@Gemtastic two things
1. You can start writing code under the assumption that JooQ will work
and 2. If you don't get something in the manual, ask me, I'll try to understand it myself.
 
fge
@Gemtastic read section 5
And if that's not enough:
Read section 5
And if again that's not enough:
Read section 5
 
@SecondRikudo I really don't even know what code I am supposed to write without jooq
@fge I can't even make out what in the manual is section 5.
 
6:06 PM
@Gemtastic there's a table of contents :P
 
fge
As to what you are supposed to do you should be able to create the DSLContext object with what we discussed, right?
 
@SecondRikudo dude are these the normal times that you are awake? where you livin at? country
 
@SecondRikudo I know but I have no idea what's what in that mess :/
 
@LeeJeong Israel
50 secs ago, by Second Rikudo
http://www.jooq.org/doc/3.5/manual-single-page/#sql-execution
 
Ok, your ahead of about 5 hours i guess.. then its what there? 6 or 7 AM?
 
6:08 PM
8 PM
UTC+2
@fge TBF this manual assumes a lot of SQL knowledge.
 
its the 16th or the 15th in there?
 
If you know JDBC the manual will make sense. I don't know JDBC :(
Well, I'll keep reading
 
@Gemtastic holy shit.
 
@LeeJeong 15
@LeeJeong ..?
 
^that's me
 
6:09 PM
@Gemtastic Including the 9gag booger?
 
ahh, so im the one ahead. OK. thanks! there's someone I can ask aside from @fge and @Unihedro
 
I feel so incredibly stupid right now :/
 
fge
@SecondRikudo only reasonable proficiency, not a lot
 
@Gemtastic no dude. what were you using in java to access DB before?
 
fge
It assumes that you can use select ... from ... where
 
6:10 PM
@fge dudette*
 
fge
That's not much
 
@LeeJeong Nothing, I'm learning this for the first time
 
fge
@LeeJeong you can help @Gemtastic too, you know JooQ as well now ;)
Teach CRUD for instance
 
honestly, it was a HOLY WOW when i discovered JOOQ. I was writing things plain JDBC API and in poor design.
 
fge
I know you use it (I don't)
 
6:11 PM
More than me at least; you've managed to make a query, I haven't
 
@Gemtastic ok, but you know basic SQL right?
 
Neither do I know how to hash passwords or how it works.
I know what a hashed pasword is though
 
it doesnt matter at the moment.
 
@LeeJeong Yes
 
or does it?
 
6:12 PM
It does because I have a long-in feature
 
@LeeJeong I come from a long history of writing things with raw SQL
raw SQL != bad design
 
holy, i guess you need to read basic SQL first and try out CRUD ops (Create, Retrieve(Or Select), Update, Delete) statements
 
bad design == bad design
I discovered the Data Mapper pattern long before I discovered ORM
 
@SecondRikudo i dont mean, using raw means bad design.. i mean I was writing JDBC all over my app.. its not layered and stuff
 
And I think that Data Mapper is superior to ORM in most ways.
 
6:13 PM
@SecondRikudo oh, so Data Mapper is a design pattern???
 
@LeeJeong That's your fault, not JDBC's :P
@LeeJeong Yes, it is.
!!tell LeeJeong google data mapper poeaaa
 
@SecondRikudo of course. no debate about it. I was just trying to tell gems how I came to discover JOOQ and how i appreciated it so much
@SecondRikudo heard of design patterns only from HeadFirst books.. anything else, I dont have an idea. ahaha
 
@LeeJeong design patterns are nothing really hard and complicated.
They're names given to certain approaches which are considered a good solution to given problems.
 
6:16 PM
@Gemtastic dude, I think what you need first to accomplish is to read SQL tuts on basic database operations (CRUD). Like adding, retrieveing, editing and deleting records
 
It's easier to say "I typed on my keyboard" than "I used my fingers to tap on keys in the keyboard in a sequence to form words"
 
@LeeJeong No I don't need that, I need know how to do that in java with jooq
 
@SecondRikudo right. I'm not debating or anything dude. xD I was just confirming if it was a design pattern coz it was new to me.
 
@LeeJeong Yeah, I'm not arguing either, rather explaining :P
 
The raw SQL is the only thing I've learned these last 5 weeks
 
user1804599
6:17 PM
For non-static methods, is synchronized void f() { g(); } the same as void f() { synchronized(this) g(); } or are there subtleties?
 
@SecondRikudo oright~ :)
@Gemtastic you basically replace the SQL keywords with the JOOQ functions.
SQL be like: SELECT * FROM STUDENTS WHERE ID = 15
JOOQ be like: create.selectFrom(STUDENTS).where(STUDENTS.ID.equal(15))
^ thats a retrieval example.
 
Hmm
 
@LeeJeong What's create?
Some sort of query factory/builder?
 
I need to sleep. have a fucking work tomorrow.. :( and my side job is fucking infested with my old DAO/DAOImpl getting obsolete because of the new JOOQ implementations. this will really save my ass..
 
please can anyone tell me, how I can can change

while (response.equals (" y "));

to include yes, yeah, yep...
 
user1804599
6:20 PM
Scala only has the latter so I guess there's no difference between the two.
 
anything that begins with a y
 
@SecondRikudo yep. some kind of a factory. Its a DSLContext class something. yeah, a factory with preconfigured settings based on your used DB
 
fge
@SecondRikudo that's the DSLContext I explained how to obtain yesterday
THe manual calls it create, I call it jooq
 
@mikeeustace Seriously I google "java search string beginning" and get decent results
 
@mikeeustace why not just get the first out of the string array and make a if statement?
 
6:21 PM
@mikeeustace try while (response.equal(" y ") || response.equal("yes") || response.contains("y"))
 
Preferably you should remove white space on the string first
 
@LeeJeong No...
 
@Gemtastic - that'll take hours (for me :( )
@SecondRikudo I didn't know the words to google
@LeeJeong - why is Second saying no? Bad form?
 
@SecondRikudo i dont know. ahaha. off to sleep, see ya guys tomorrow. FML hard. living with two jobs
 
@fge FFS Do you understand why I don't like Java?!?!?!!! XD
Everything needs this AbstractContextImpl object and that SomeWierdassInterfaceImpl object
 
fge
6:23 PM
No
 
@SecondRikudo kindly explain before i sleep
 
fge
No they don't
It's simply what you know of Java which makes you say that ;)
 
explain...
ahahah.
 
@mikeeustace response.contains("y") will match "why" as well
 
fge
When you have practiced as long as I have, this is a non problem
 
6:23 PM
@fge When you get tazed enough times, you develop immunity to it too.
 
@mikeeustace It really doesn't take hours. Modifying a string to shave off white space and getting a specific char in a string is are some of the first things you learn so it's easy and all over the internet
 
@SecondRikudo @mikeeustace i figured using .contains coz all of his entries have y's but that just quick dirty sol
 
fge
@SecondRikudo meh, you'll never change opinions, so I won't try to convince you, but don't assume you know best, nobody does ;)
 
I'll have a go @Gemtastic

Thanks all
 
ok, im going to sleep now. I have to hunt a lot of fetchOne methods tomorrow. fvck. good night fellas~
 
6:25 PM
@mikeeustace assuming response is a String, response[0] contains the first character
 
@SecondRikudo i know that of course.. ok night now. ;)
 
@fge I never assume I know best :P
I often talk like I do to draw fire, so I can learn new stuff.
 
@mikeeustace Remember; a string is an array of chars. You can treat it like an array.
 
haha - you say remember, but you're actually teaching me for the first time! :)
 
@SecondRikudo You want us to fire all the good facts at you? Good troll
 
6:26 PM
Cunningham's Law is a powerful tool.
 
thanks for that!
 
@LeeJeong What?
 
@mikeeustace No, remember the fact I told you
is what I meant
 
@Gemtastic Imma try setting up a hello world example for you
 
I didn't know strings were arrays of characters
 
6:27 PM
Let's see if I understand JooQ enough myself :D
 
@SecondRikudo ♥♥♥
 
@mikeeustace No they're not
 
"@mikeeustace Remember; a string is an array of chars. You can treat it like an array."
@Unihedro - they're not but I can treat it like one?
 
Unless you use Pascal. Even then AnsiString isn't string because the language is horribly broken
@mikeeustace Well, you can't. String is an abstraction. While .toCharArray does give you the underlying presented char array, it is not guaranteed to be correct as the abstraction.
Take characters in your string outside \u0000 ~ \uFFFF for example.
 
6:32 PM
The Pascal version of String being an array will give you a clear idea: "hi"[1] is h
 
okay
 
But var str : string = "hi"; Stack Overflow str := copy(str, 0, 2); write(str[1]) compiles
But runtime error because copy returns an ansistring
BECAUSE PASCAL IS HORRIBLY BROKEN
/end rant
Excuse me while I find and kill @LeeJeong for waking me up at 2 am for no apparent reason
Wait, [main] became a link to SO
:/
 
afraid you lost me :)
 
@Unihedro Don't confuse him
@mikeeustace in Java, you can treat any string like an array of chars.
It's not 100% how it works behind the scenes for real, but you can treat it as such.
 
Thanks @SecondRikudo
that's all I care about...
 
6:47 PM
I ended up downloading jdk8 over my mobile's tethering connection
200MB off my package XD
 
Can anyone see why my code's broken? It compiles but the blue circle mouse pointer (win 8) is there!

http://pastebin.com/cmxYb0Xp
 
@SecondRikudo and why did you do that? :P
 
@ItachiUchiha Forgot I was tethering, realized half-way through
 
lolz
 
CBA download over 100MB again just because
Alright @Gemtastic now I'm gonna need your help a little XD
I downloaded jOOQ, it's a .zip file with a crapton of .jar files inside
Where do I stick them so that they'll be available to me? XD
<-- never made a project with dependencies in Java from scratch
 
6:51 PM
@SecondRikudo In your project dependency
Ahh, I see
First, are you using a build tool?
 
@ItachiUchiha I'm currently using Intellij, I created a completely vanilla project.
 
So, no build tool. It is just a default IntelliJ project.
 
@ItachiUchiha Yup.
I can use anything though
 
better go with maven or gradle later, but for beginner, go with the above link :P
 
@ItachiUchiha So just stick in in the project root somewhere, and add it from that GUI?
 
6:58 PM
Well you can create a folder in the project, name it as lib and add the jars in it
Then configure the dependency management as described above
the benefit with maven/gradle is that you don't have project/module specific jars. All the jars are stored in a centralized location and shared by all the projects :D
 
I think I'll go with gradle
 

« first day (1604 days earlier)      last day (3341 days later) »