I recently explore an article on hibernate best practice over here https://thoughts-on-java.org/hibernate-best-practices/
I came across a topic
Use JPA Metamodel when working with Criteria API
@Generated(value = “org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor”)
@StaticMetamodel(Author.class)
public abstract class Author_ {
public static volatile SingularAttribute<Author, String> firstName;
public static volatile SingularAttribute<Author, String> lastName;
public static volatile SetAttribute<Author, Book> books;
public static volatile SingularAttribute<Author, Long> id;
public static volatile SingularAttribute<Author, Integer> version;
}
I am still not able to understand what is the role of volatile
over there as we know that values of volatile variable will never be cached and all writes and reads will be done to and from the main memory.
please can anyone clarify me, what exactly we want to achieve by using the volatile
keyword? Don't you think the above code causes performance issues.