Wednesday, 30 September 2015

Spring Validation - collection max index.

Since Spring 3 DataBinder have aditional validation of collections which prevents out of memeory attack. This validation default limits collection size to 256 elements of collection.
If you need to increase this limit you have to use method setAutoGrowCollectionLimit before you register custom editors.

Tuesday, 29 September 2015

Angular structure and remote templates

At weekend I tried to clean my Angular project and move modules to separate files and folders. I did this but at the beginning nothing was working. I defined separate modules like:

angular.module('App', []);

In this square brackets I have to put names of other modules that are required to use in that App. That modules are injected by name.

angular.module('App', ['MyValidators','MyFilters']);


I exclude html templates to external files and use them by url.

<div .... ng-include="'templates/myTemplate.tpl.html'" />

Tuning Oracle queries with null values

Today I tested two queries in Oracle database. I noticed that when I execute query there column value is null, oracle engine directly use full access to table. I created index like:

create index MY_IDX on MY_TABLE (COLUMN_CAN_BE_NULL, -1);
and I have to use hint to use that index. Automatically oracle used full access, even when I counted statistic for this table.
However when it used index like this, it took much more then full access.

I have to dwell on a subject....

Friday, 25 September 2015

log4j and additional log param

I didn't know that so easy you can add to logs for example http session id. You need only put into MDC object value and later set log pattern as %X{sessionId}.

When I did that I had to find good place to put into MDC my sessionId parameter. I created web filter to archive that. Filter is simple and should be executed in correct order in chain.

LINK


I have to admit I had problem with logging exception stack trace. I implemented ThrowableRenderer and have set throwableRenderer tag.

SRC

AngularJS interceptor

I created AngularJS service and connection to server. On server side was Spring Security and I used CSRF. I'd like natty add this token to every request.

The best way to do that was create interceptor "csrfInterceptor"

App.config(["$httpProvider", function($httpProvider) {
    $httpProvider.interceptors.push("csrfInterceptor");
}]);

and push it into provider interceptor.

AngularJs filters

How it is easy to create in AngularJS filter I got to know when I need some special conditions.
I need to filter list of elements like this:


item in ptfs | showFilter: searchCriteria

I created filter called "showFilter" with filter criteria "searchCriteria".

Filter looks like:

App.filter('showFilter', [function($filter) {
   
    function isNotEmpty(obj){
        return obj != null && obj.trim().length > 0;
    }
   
   
    return function(inputArray, searchCriteria){      
       ....
       return data;

     };

}]);


Function returning data is a filtered copy of input data.

Thursday, 24 September 2015

ehcache and junit

Yesterday I upgraded ehcache lib to 2.8.4 in supported by me application. I have run tests and I saw in logs a few lines of notice.

Notice says, there is another CacheManager in JVM. I had to think a while. I changed configuration files and I gave them a name but it didn't fix it. I debugged this and I saw that every test is run there is loading new instance of configuration and there is created new CacheManager with known name.

I searched a little in google and I found out that I can downgrade libs to version 2.4.x or turn off cache during the test. I chose first solution.

Thursday, 17 September 2015

Language loophole

Yesterday I was arguing with my colleague about meaning of sentence. Sentence is like:
You have put A instead of B.
I understood this sentence what I have to do something instead of I have done something. Little difference in sentence but huge difference in meaning.

Tuesday, 15 September 2015

SQL and null conditions

Today I found in my SQL package code one bug. I created function/procedure with a few input parameters and used them in simple sql query as condition. In some cases that input parameters are null. I used that parameters with = sign. However oracle interpret construction like:
some_column = input_val
even column and input_value are null as not fulfill condition.

In older oracle sql it is possible to use function decode(some_column, input_val, -1) = -1 but it is not performance
In newer oracle db you can create index like:

create index some_index_name for table_name (some_column, -1)

You have to look out for possible values in some_column.

Monday, 14 September 2015

JPA 2.0

JPA 2.0 has a few useful things like:
  1. API to basic caching
  2. Unify database source parameters, ex username or password
  3. Improve lock modes
  4. Use advanced JPQL language to create queries
  5. Extends presisting API

ResultSet by Hibernate

In hibernate you can use 3 types of Scrollable ResultSet:
  1. TYPE_SCROLL_INSENSITIVE - it is possible to get selected row of data and retrieve data forward and backward. There is not sensitive for external changes in db, so as I got to know refresh is impossible.
  2. TYPE_SCROLL_SENSITIVE - the same as above but it is sensitive for external changes in db. After calling refresh you get new entity from db.
  3. TYPE_FORWARD_ONLY - it is possible to get data only forward order, you can't get selected row. It is necessary to go in loop by next method.

My first post

Today I thought that I can collect notes about new things I get to know this day. I'd like to write this blog mostly in English or other languages which aren't my native language.