Friday, September 27, 2013

The Law of Demeter will tell you the truth

    The Law of Demeter (LoD) is well-known in object oriented programming. Can we get to know something unusual from that principle?

Tuesday, September 3, 2013

Hibernate configuration example with in-memory H2 DB for ad-hoc testing

    Sometimes I like to play a little bit with Hibernate. I do not want to spend much time on configuration or DB schema creation so I keep prepared piece of code.

Saturday, August 31, 2013

@PrePersist and @PreUpdate - not working with Hibernate 4 Session and Spring

    @PrePersist and @PreUpdate annotations have their roots in JPA specification. Hibernate implements JPA specification. However, if we decide to use SessionFactory and Session instead of EntityManagerFactory and EntityManager, we will realize that mentioned annotations are ignored. Is there a way to solve the problem?

Saturday, August 10, 2013

IntelliJ - GIT push problem

    IntelliJ seems to be an interesting IDE, however recently I had an issue related to it's GIT plugin.

Saturday, July 27, 2013

Contextual session-local Hibernate interceptor with Spring

    Hibernate interceptor can be used for various purposes, e.g. audit trail, simple logging of persistent operations. However, we should have on our minds the fact that Hibernate SessionFactory level interceptor has to be implemented in a thread-safe manner, because it will be shared among all of the sessions. Is there any way to implement the interceptor with single-thread programming model?

Saturday, July 6, 2013

EJB vs. Spring thread safety

    EJB and Spring are capable of providing ecosystem for the implementation of business services. EJB is more specific in its purpose whereas Spring brings us a great deal of flexibility. Can the freedom of Spring be dangerous?

Saturday, June 22, 2013

Configuration trash

Just create this entry to keep various configurations in a central place. I am going to update it in the future - when it is necessary.

Saturday, June 8, 2013

Async logging performance with log4j

We do it all the time:
log.debug("Log me");
This particular line does three things:
1. Saves the message to some storage,
2. Obfuscates the business logic,
3. Slows the execution down.
However, there are moments when the performance is crucial. Can async logging help us in that matter?

Friday, May 24, 2013

When Dead Letter Queue becomes a zombie

    Dead Letter Queue (DLQ) defined within JMS provider is known to be a basket for messages that cannot be delivered to a particular destination. A typical scenario is that a DLQ is defined, a consumer of dead messages is attached and everything seems alright. It gives some kind of mental comfort. But is it real?

Saturday, May 11, 2013

Why can we use Enums as HashMap keys?

    Last time when I saw enum used as a HashMap key I decided to check why it works out of the box without custom implementations of 'hashCode' and 'equals' methods.