Java articles

Repositories with Criteria queries in Spring Data

Previously we discovered the advantages of repositories compared to classic DAO layer. We saw that repositories supported both native SQL and JPQL queries. But do they support other features of JPA, as Criteria API ? Yes, and we'll see it in this article.

Continue Reading β†’

SpEL in Spring Data queries

Spring Expression Language (SpEL) est is used often in Spring Security project. But Spring Data also supports it.

Continue Reading β†’

JPA criteria queries

Querying database with JPQL queries is quite simple. But a main drawback of this solution is its static character. To create dynamic queries, a more adapted solution exists, JPA Criteria.

Continue Reading β†’

Static metamodel in JPA

Entity modeling looks like the most important and the single meta data associated with a Java class in JPA. But it's not alone. Static metamodels are a meta data describing entity too. Unless, they are used in different purposes.

Continue Reading β†’

Asynchronous events in Spring

Synchronous events have one major drawback: they're natively executed in the calling thread. If the listener handling on of synchronous events takes 5 seconds to respond, the final user won't able to see the response within at least 5 seconds. However, one alternative solution is proposed to this problem - asynchronous events.

Continue Reading β†’

Asynchronous and scheduled tasks in Spring

Native Java offers a lot of possibilities to create thread pools, retrieve task results as Future instances. But Spring isn't worse and with its scheduling package allows to work with threads executed in background.

Continue Reading β†’

Google Guava : future chaining and transformation

In one of previous articles we saw that Google Guava provides a listenable futures which are able to invoke callback methods. But it's not theirs single feature.

Continue Reading β†’

Just-in-time compilation in Java

Like some other programming languages, Java is also commonly called "compiled language". However sometimes you may be confused when somebody tells you that Java is JIT compiled.

Continue Reading β†’

Custom filter in Spring Security

Until now we've working with filters belonging to Spring Security project. However we can also add our own custom filters which must only follow some basic rules.

Continue Reading β†’

Effects of bad filter order in Spring Security

Spring Security is based on filter chain. Every filter can be invoked for appropriate request and executed to provide supplementary layer of protection. But one important thing must be respected - filters order.

Continue Reading β†’

Custom namespace parser in Spring

In Spring we can configure dependencies in several ways: with XML files or directly in Java using annotations. This first way is usual considered as clearer and simpler to maintain. And if you're working with it, you certainly met some of Spring XML namespaces, as those one for Spring Security or Spring MVC projects. In this article we'll focus on this aspect of Spring.

Continue Reading β†’

Inheritance types in JPA

In the previous article about JPA we discovered how to create Java objects inheritance tree directly from a single database table with discriminator annotations. In this occasion we discovered also another interesting annotation, used to define inheritance type - @Inheritance.

Continue Reading β†’

Single table inheritance with discriminator in JPA

Sometimes database data can be simply reflected in Java objects. But in other situations, when for example one database table stores several types of Java objects, it can be more difficult. And for these situations JPA uses discriminators.

Continue Reading β†’

Different temporal types in JPA

Temporal information is very precious for all marketing purposes, as birthday e-mailing or several other reminders. JPA has specific annotation to handle this type - @Temporal.

Continue Reading β†’

Embeddable objects in JPA

In some situations @Entity annotation can be useless and we can still need to use Java objects as objects managed by JPA provider. In these cases we can use embeddable objects, representing by @Embedded and @Embeddable annotations.

Continue Reading β†’

Splitters and aggregators

With more and more data to send, enterprise integration applications can become less and less usable if code and architecture don't evolve. Beside these two key elements to improve growing system performances, Spring Integration provides another one, called messages splitting and aggregation.

Continue Reading β†’

Routing

Beside static-looking XML configuration, Spring Integration provides some dynamic mechanisms. One of them is routing which allows one message to be received by dynamically resolved message channel.

Continue Reading β†’

Transformers

In one from first articles about Spring Integration we discovered the idea of conversion service. However, it's not only one element which can change message from one format to another one. The second element is message transformer, in integration world known also as message translator.

Continue Reading β†’

Message handler chain, filters and header enricher

New concept described in this article will be chaining. Exactly as in another domain of life, chaining in Spring Integration allows to group together a set of elements. At this occasion we'll also discover some of elements which can be defined inside chains: filters and header enrichers.

Continue Reading β†’

Messages and message handlers

This time we'll cover more core concepts of Spring Integration: messages and another concept with 'message' in the name, message handlers..

Continue Reading β†’