I have entity. When I use method save()
of my JpaRepository
, the record is inserting into database. Database has trigger, which modifies the record. But save()
, and also findById()
returns to me old unmodified value, from cache I suppose. Executing EntityManager.clear()
solves problem, but I am not sure it is correct way.
How to tell findById()
to do queries to database instead of cache? I have tried @CacheEvict
, @CachePut
annotations, but seems nothing works.
Entity class:
@Entity
@Cacheable(false)
@Table(schema="adm", name="datasets")
public class Dataset implements IEntity<Integer> {
private static final long serialVersionUID = 1L;
@Id
@Column(name="id", nullable=false, insertable = false, updatable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "guid", insertable = false, updatable = false)
private UUID uuid;
@Column(name = "schema_name", insertable = false, updatable = false)
private String schemaName;
@Column(name = "title")
private String title;
@Column(name = "description")
private String description = "";
@Column(name = "src_image_type")
private String srcImageType;
@Type(type= "com.luxms.bi.entity.jpa.BIJsonType")
@Column(name = "images")
private BIJson images = new BIJson();
......
}
Repo:
import com.luxms.bi.entity.BIDataset;
import org.springframework.data.jpa.repository.JpaRepository;
public interface DatasetRepository extends JpaRepository<BIDataset, Integer> { }