Hibernate, Quick solutions, Spring Framework

How to solve: java.lang.IllegalArgumentException: Not an managed type

This is the first post of series “quick solutions”.

I have met issue mentioned in the topic in my current job. The reason occurred to be pretty simple. I have written wrong path in packagesToScan parameter of LocalContainerEntityManagerFactoryBean.

public EntityManagerFactory entityManagerFactory() throws PropertyVetoException {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();

    return factory.getObject();

As a side note, Hibernate forces us to have default constructor (without params) in all managed entities, but exception is different then and looks more like the one I pasted below:

org.hibernate.InstantiationException: No default constructor for (…)

AssertJ, Java, JUnit, Maven, Mockito, Spring Framework

I against U

As we know now, that we should test each and every part of code, it is time to cover our application with tests. We can distinguish two main types of automatic tests:

  • unit
  • integration

Today, I’m going to show you how to set up environment for testing purpose using IntelliJ, maven, jUnit, AssertJ, Mockito and Spring Framework.

Continue reading