Matchlogger: April summary

Time for a summary of April in terms of Matchlogger. The summary would be short – it’s not going too well.

The only functional part of the application that I was able to work in April was adding matches. With that part, I haven’t even finished it yet. Apart from adding matches, I briefly experimented with adding Content-Security-Policy header to the application, but that also wasn’t finished. At this point, it is quite clear that with current pace, by the end of May I won’t yet have a working MVP of my application.

With blogging, it went much better. Even though I had to take a one-week break because of personal reasons, seven posts have been published in April and that one will be the eighth. Writing text was going well enough that I’m wondering if in my case blogging isn’t ahead of coding in this contest – as I have to write 2 posts a week and do some research for the app, but not necessarily write code. This month, technology posts had worse traffic than my travel- or soccer-related posts – while my live travel post (PL) brought 84 visitors to the blog, the best technology post had 27 visits.

How about the April posts?

  1. Where can I deploy my Java web app? – 11 visits
  2. Content-Security-Policy: manage security settings of your app – 10 visits
  3. Amazon Glacier: storing backups you don’t need too often – 10 visits
  4. 15 things you learn about Java for OCA exam – 9 visits

…and then there is an abyss of posts having a maximum of three visits.

What may be my May plan?

The plan is quite short – less blogging, more coding. Nearest planned issues I want to deal with are:

  • adding matches – it’s important to finish it.
  • recording that user went to the match
  • creating an admin panel for accepting new teams
  • deploying the application on a server.

The added problem is that during the last week of the contest, I won’t be blogging nor coding due to other commitments. So, in fact, I have three weeks. We’ll see if I manage to do all that 馃檪

Stay tuned for next Matchlogger updates!

Using reserved MySQL words as Hibernate field/table names

As I came back to Matchlogger development today after a short break, I wanted to implement adding matches. I added a Liquibase migration, created all the required repositories and an entity class that looked like this:

When I opened the application and triggered a controller method that aimed to get all matches from the database, I saw an error message and a stack trace that had a cryptic message at the top:

2017-04-24 20:08:29.337 WARN 3190 --- [nio-8080-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 1064, SQLState: 42000
2017-04-24 20:08:29.337 ERROR 3190 --- [nio-8080-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'match match0_' at line 1
2017-04-24 20:08:29.357 ERROR 3190 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'match match0_' at line 1
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_121]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_121]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_121]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_121]
...

Not exactly the most meaningful message. So I added more logs into application.properties (Spring Boot FTW):

spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.use_sql_comments=true
spring.jpa.properties.hibernate.format_sql=true

Right now I at least had an SQL that I could run:

sql> select
  match0_.id as id1_1_,
  match0_.first_team_id as first_te3_1_,
  match0_.match_date as match_da2_1_,
  match0_.second_team_id as second_t4_1_
from
  match match0_
[2017-04-24 20:09:08] [42000][1064] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'match match0_' at line 7

As you can see, the message is still cryptic. There is a mention of error 1064 here. I found a reference that suggested that it might be because of reserved words. DB engines use some specific words that may be part of their syntax and using them usually requires adding backticks to the name. Is match such a word? Turns out it is.

How to solve that?

The solution is simple. The only thing I needed to do was to add quotation marks to the table name in entity class:

You will see the same issue especially with users. An obvious choice is always naming the table with users records as user which is a reserved, well, anywhere I remember. I did foresee that one and named the table ml_user, but didn’t expect to come across the same issue with matches.

Powr贸t na Ba艂dowsk膮: Wis艂a Tczew – Sobieski Gniew (1:2)

Uwaga, wpis zawiera du偶e zdj臋cia. Przed klikni臋ciem na „Read more” upewnij si臋, 偶e nie masz ograniczonego pakietu internetu.

Dok艂adnie pami臋tam m贸j pierwszy obejrzany na 偶ywo mecz. To by艂 sierpie艅 2002 roku i poszed艂em z tat膮 na wchodz膮c膮 w艂a艣nie do trzeciej ligi Uni臋 Tczew. Na stadionie przy ulicy Ba艂dowskiej na meczu z Amic膮 II Wronki czu艂o si臋 atmosfer臋 艣wi臋ta – na oko przyszed艂 ponad tysi膮c os贸b, rozdawano przygotowan膮 specjalnie na ten sezon gazetk臋 klubow膮, mo偶na te偶 by艂o kupi膰 kie艂bas臋 z grilla. Unia wygra艂a 3 – 1, zapami臋ta艂em szczeg贸lnie bramk臋 Marcina Chy艂y.

Unii w rozgrywkach klubowych ju偶 nie ma – jej nazw臋 nosi dru偶yna z艂o偶ona g艂贸wnie z oldboj贸w, kt贸rzy co sezon startuj膮 w Pucharze Polski. Jest za to reaktywowana 1,5 roku temu Wis艂a (obecnie w A-klasie), kt贸ra wi臋kszo艣膰 mecz贸w rozgrywa艂a dot膮d przy ulicy Ceglarskiej, ale w rundzie wiosennej z jakiego艣 powodu graj膮 na stadionie miejskim przy ul. Ba艂dowskiej. Na ich meczu dzi艣 si臋 znalaz艂em.