Hibernate Query unexpected token: INTERVAL

I'm trying to fetch inventories which is opened at last month, for traditional SQL DATE_SUB function should be used here for date calculation. So the HQL is like following


But following error appeared when running it in Hibernate QL Query Consonle in Intellij IDEA


Unfortunatelly the INTERVAL keyword is not supported in HQL.



An alternative is to calculate the date in Java and pass the result dates to HQL as parameters. The code is like following


Implementation code for DateUtil.getLastMonthFirstDay and DateUtil.getLastMonthLastDay




GitLab took too much memory

The gitlab execution on our company internal server eats lots of memory, the server has 32G memory, and gitlab took more than half of it.


I found there are lots of unicorn processes running, and each unicorn process is taking 1.5% memory
In top  command output it's displaying as ruby process and took nearly 500MB resident memory (by default top is sorting by cpu usage, pressing < or > key to change sorting column)
Running above command outputs 34, that means at most 34 unicorn processes are running (some other processes' name also contain unicorn)..
Assume there are 30 real unicorn process running, each takes 500MB memory, then they will take 30*500MB=15GB memory
To decrease unicorn processes count, edit /etc/gitlab/gitlab.rb, and uncomment following line


Next restart GitLab

Now the memory usage is decreased.


(Note that running gitlab-ctl reconfigure  will not kill already running unicorn processes)

HBase scan with multiple versions

HBase support multiple versions of data, when modifying a value, new version will be saved with timestamp.

Scan with versions

This will scan the table and number of versions is 4

Scan with versions and time range

We can also filter versions data further by time range.

CentOS 6 Install netcat

Netcat is one utility in NMap toolset, it maybe named as nc, ncat or netcat on different Linux distributions. (It's ncat on CentOS 6).

On CentOS 6 netcat is not installed by default, to install it we can run following command


Then run following command to check netcat is installed correctly


Cannot install Docker on CentOS 6

Installing docker-ce on CentOS 6.9 got following error


To install docker on CentOS 6, run the following command


Then run

Its output is

Docker version 1.7.1, build 786b29d/1.7.1


We can see docker is installed successfully.

Spring Cloud Zuul Ribbon custom rule not working

I need a custom Rule which can route requests to different service according to weight option (actually I want to deploy an A/B test service and only small percent of user will hit it), the code is like following


And following is application.yml configuration file


Adding breakpoints at constructor of ZoneAwareLoadBalancer and DynamicServerListLoadBalancer, then access the Zuul service via browser and I found ZoneAwareLoadBalancer constructor breakpoint is reached first.

Inspect the value clientConfig->properties->NFLoadBalancerClassName, its value is still "com.netflix.loadbalancer.ZoneAwareLoadBalancer", and the passed in rule is not my configured rule as well.

This means my configuration didn't work.


Even I changed the class name to an invalid value, there is no error


In Spring Cloud documentation, under Customizing the Ribbon Client using properties section, it's saying

Starting with version 1.2.0, Spring Cloud Netflix now supports customizing Ribbon clients using properties to be compatible with the Ribbon documentation.

Checking maven pom file I found it's using 1.1.0


Changing them to 1.2.0 and run again, following exception is thrown


It's because NFLoadBalancerRuleClassName is aaa, changing it to a valid name and try it again, it works now



Docker SSH set password not working

First run passwd  command to change the password, after inputting new password, following output is shown.

passwd: password updated successfully

I bind docker port 22 to host port 33333, then running following command to connect to it using ssh with the new password we set earlier

After inputing password, following error is appeared

Permission denied, please try again.

SSH logs from /var/log/auth.log


To fix this issue, change /etc/ssh/sshd_config


Restart sshd and connect to it again, it should work now.

Specified key was too long; max key length is 3072 bytes


When running above statement to add unique index, following error happened.

[2018-03-28 11:38:24] [42000][1071] Specified key was too long; max key length is 3072 bytes


Table structure

So the above index key length is value(255*3), productId(4), productName(255*3), productSerialNumber(255*3), userPhone(255*3), userName(255*3), userId(8), type(255*3), statStartTime(8), statEndTime(8)

Total length is 255*6*3 + 4 + 8*3=4618 is greater than 3072 bytes.


Note that the charset used is UTF8, so every character will occupy 3 bytes.



Then change to following statement, and the error is fixed.


Another solution is to increase this 3072 bytes limit.

Intellij IDEA plugin development get selected text

To get selected text in a Intellij Platform Plugin project, we can use following code


The first line is used to get current editor object


Then call getSelectionModel and getSelectedText method to get selected text


The last two lines is to to some operation for selected text, it's unrelated to our goal.



HBase get column qualifiers by column family

To get column qualifiers by column family we can use following code

Above code will outputs all column qualifer names of family map "basicInfo" in table "merchants".


And following code shows different ways to retrieve HBase cell value


  • Get Cell by Family Map and Column Qualifier

This line of code retrives cell value by family map "merchantNo" and column qualifier "string"


  • Get All Cells by Faimily Map

result.getFamilyMap(Bytes.toBytes("merchantNo"))  will return column family map with name "merchantNo", it contains column qualifier name as key and cell value as value.

Above code will iterate the column family map, and outputs each column qualifier and its corresponding cell value.