Tuesday, December 23, 2014

err: non-serializable object

I'm using Cacheable annotation and getting "err: Non-serializable object" from the underlying caching mechanism (memcache). My code was such as this:

public class MyResult implements Serializable
{
private MyEnum myEnum;
private AnotherObject anotherObj;
}
It is implementing Serializable why it would not work? That's because I forgot that every object in my class must also implement Serializable. So adding this to AnotherObject fixed my problem. But I did not implement Serializable in MyEnum, why it worked? It worked because enums in Java by default implement Serializable.

Wednesday, December 10, 2014

unknown column 'date' in 'field list'

When working on a project in which we use hibernate, I get
Unknown column 'date' in 'field list'
as exception. The spring exception was:
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; SQL [select this_.ID as ID3010_0_, this_.date as date3010_0_,
The only field I have in my entity named 'date' is not marked with column annotation. So it should not be mapped to database table and thus should not be used in the query right? No, think again. Every field in the entity class is mapped and column annotation is optional. So if you ever want hibernate to ignore a field in your entity (because either this field is not present in the table or you don't want to use it somehow), use transient annotation. So,
@Entity
public class MyEntity implements Serializable
{
    private String date;

    @Id
    @GeneratedValue
    @Column(name = "ID")
    private Long id;
must become this
@Entity
public class MyEntity implements Serializable
{
    @Transient
    private String date;

    @Id
    @GeneratedValue
    @Column(name = "ID")
    private Long id;

Thursday, September 25, 2014

docker presentation

You can find the Docker presentation I did for Sony eurasia below.

Tuesday, July 1, 2014

access to dialectResolutionInfo cannot be null when 'hibernate.dialect' not set

While I was trying JPA stuff on Spring Boot I had a "Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set" exception. I was using "spring-boot-starter-data-jpa" and everything seemed to be in place but still I was getting this. Later I realized that I did not include my database's dependency. After I added it to my pom the problem was fixed.



  postgresql
  postgresql
  9.1-901.jdbc4

Thursday, June 26, 2014

spring boot presentation

Yesterday I did a Spring Boot presentation at Sony Eurasia. Here are the slides: