Observations about OData and Spring Data REST

Recently I had a chance to spend some time reading about OData and experiment with Apache OLingo Project in order to understand what OData provides us with in terms of making our REST services more standardized and self discoverable. I also compared it with Spring Data REST Project, what are their similarities and differences, whether […]

Factory Method Pattern Implementation of Spring: FactoryBean

Factory method pattern aims to encapsulate object creation process within a separate method in your system. That’s why it is called as so. Factory methods can be created as either static or instance methods within a class. In Spring Application Framework, although it is possible to make use of static or instance factory methods to […]

A Slight Difference Between Autowire byType and constructor

Spring documentation states that both autowire byType and constructor modes expect at most one bean definition in the ApplicationContext, so that it can be autowired into the depending bean. Here is the excerpt taken from Spring Reference Documentation Table 6.2. Autowiring modes; byType Allows a property to be autowired if exactly one bean of the […]

A Transaction Gotcha When Using Spring with Hibernate

Spring’s transaction propagation rule SUPPORTS states that if there exists a transaction when the method is called, it should work within that transaction, otherwise it should work outside any transaction. Similarly, transaction propagation rule NOT_SUPPORTED states that if there exists any active transaction when the method is called, that active transaction should be suspended before […]

What is the difference between Strategy and Template Method patterns…, if there is any?

In our Spring book, we discuss about transaction management mechanisms available in the Spring Framework, namely declarative and programmatic transactions. It is further explained inside programmatic transaction demarcation section, that how programmatic transaction can be achieved using different methods. One of the ways programmatic transaction can be achieved is, using TransactionTemplate utility class provided by […]

Things to Fix When Upgrading from Spring Security 3.2.x to 4.x

Some things have been changed in Spring Security 4.x compared to previous 3.2.x branches. They are not overwhelming but you may have to deal with them so that your application can work without any problem after upgrading to Spring 4.x release. I noted them down during my upgrade process, and post here in case you […]

Moving libraries of web apps into shared folder

If you plan to move repeating libraries of your several web applications depend on, to a shared folder of your application server, I would definitely say NO! to this request. One of my clients asked me about to centralise such repeating libraries into a shared folder. Actually, I had written another blog post in which […]

Possible bug in Hibernate XML based mapping when using properties element

Assume you have a Person with firstName and lastName properties, and a subclass of it called as Vet. You will have hbm.xml mapping files with the following content. Person.hbml.xml <hibernate-mapping> <class name=”com.javaegitimleri.petclinic.model.Person” table=”persons” abstract=”true”> <cache usage=”read-write” /> <id name=”id” column=”ID” access=”field”> <generator /> </id> <version name=”version” column=”VERSION” type=”integer” access=”field” /> <properties name=”firstAndLastName” unique=”true”> <property name=”firstName” […]

Error while generating JAXB Classes from XSD File

You may get following error when you try to generate JAXB classes from your XSD files within Eclipse IDE. Error: Could not find or load main class com.sun.tools.internal.xjc.XJCFacade The reason for this error is that you have configured Eclipse to use JRE instead of JDK. If you add a JDK through Window>Preferences>Java>Installed JREs, and select […]