I created query method in Spring Data JPA repository. I used method naming conventions. I'm not sure but it looks like Spring Data made query cache for it. I have those entity:
public class Feature {
private String desc;
private FeatureFor featureFo;
}
public enum FeatureFor {
ABC, DEF, XYZ;
}
In repository I created method with name:
public List<Feature> findByFeatureForIn(List<FeatureFor> featureFors);
This method is invoked twice from different servises. First time when it's invoked I can see generated query in console which is something like this:
SELECT ...... WHERE ((t0.featureFor = ? OR t0.featureFor = ?) AND t0.featureFor IS NOT NULL) [params=(String) ABC, (String) DEF]
This is ok. But When method is invoked via second service I can see same select generated with the same parameters. I'm sure that in featureFors parameter there were ABC and XYZ. But it's completely ignored. I also tried to use featureFors with one ABC value contained in (in first invoked service). In this case query generated was something like this:
SELECT ...... WHERE (t0.featureFor = ? AND t0.featureFor IS NOT NULL) [params=(String) ABC, (String) DEF]
Second service passed same params (ABC and XYZ) but the generated query and params did not change (it's same which generated in the first service). Does anybody knows if Spring Data creates cache for queries? I didn't realize I made some mistake. Maybe I did. I'm using OpenJPA. Thank you for your help.
The persistence configuration looks like this:
<?xml version="1.0"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="openjpa">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<class>...difened entities here (including Feature)...</class>
<properties>
<property name="openjpa.Log" value="DefaultLevel=INFO, Runtime=INFO, Tool=INFO, SQL=TRACE"/>
<property name="openjpa.ConnectionFactoryProperties" value="PrintParameters=true" />
<property name="openjpa.jdbc.MappingDefaults" value="ForeignKeyDeleteAction=restrict,JoinForeignKeyDeleteAction=restrict"/>
</properties>
</persistence-unit>
</persistence>