Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPA find() method with vendor-specific properties

I am new to JPA and I have started using it recently. I have a doubt with the following method which was introduced in JPA 2.0 -

 public <T> T find(Class<T> entityClass, Object primaryKey, 
                  Map<String, Object> properties); 

The documentation says, Find by primary key, using the vendor specified properties.

But I am unable to understand what are those vendor specific properties and under what situation this overloaded find() method should be used.

Can any one explain this to me with a suitable example. Thanks in advance.

like image 985
Manish Avatar asked Aug 07 '14 10:08

Manish


1 Answers

Look here, it's a list of query hints for Hibernate. For Eclipselink you can use these hints.

You can use hints in property map like this:

Map<String, Object> map = new HashMap<>();
map.put("org.hibernate.cacheMode", CacheMode.REFRESH);
MyClass myClass = em.find(MyClass.class, 1L, map);
like image 146
Maciej Dobrowolski Avatar answered Oct 04 '22 08:10

Maciej Dobrowolski