I read that there's a first and second level cache in using Hibernate.

I suspect for my case, Hibernate is caching the old data and I am using hibernate sessionfactory so it is retrieving the 2nd level cache data and thus the error stays the same even though I have created an entire new table manually in MySQL.

Is it possible to erase the cache data at all from somewhere ? like AppData ?

Post subject: Re: How do I prevent Hibernate from altering my database table?

Posted: Sat Nov 11, 2017 3:00 am

Hibernate Team

Joined: Thu Sep 11, 2014 2:50 amPosts: 1630Location: Romania

1. The @Id should use a Wrapper not a primitive:

Code:

private Integer tutor_id;

2. If you are using PostgreSQL or any other database that support SEQUENCE objects, you should be using that instead of IDENTITY because, otherwise, you won't be able to batch inserts automatically.

3. Providing a Constructor with more than 4 arguments sounds like a Code Smell. Use the Builder Pattern instead or a Fluent API entity.

4. You still need to provide a no-arg constructor anyway.

5. The VARBINARY column will be used if you provided a Serializable property that's not mapped as an association or as a custom type, like JsonNode for which Hibernate does not have a built-in associated native Type to handle such Object type.