I have an oracle view in which I query my db.
create or replace view my_view as
Select cc.CCID ccid
sm.SMCODE smcode,
NVL(sm.smname, cc.ccname) sname
From CC cc
Inner Join SM sm
On cc.id = sm.id;
I use jpa 2.1
and hibernate 4.3.7
to map my view to my entity.
My entity class looks like this:
public class CCRequest implements Serializable {
private static final long serialVersionUID = 1L;
private String ccId;
private String smCode;
private String sName;
}
And my mapping xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm"
version="2.1">
<entity class="CCRequest" name="CCRequest001">
<table name="my_view"/>
<attributes>
<id name="ccId">
<column name="ccid"/>
</id>
<basic name="smCode">
<column name="smcode"/>
</basic>
<basic name="sName">
<column name="sname"/>
</basic>
</attributes>
</entity>
</entity-mappings>
So I query my entity with jpa properly and it returns all my records. Here is the problem, when I change my data in DB asynchronously, Shockingly my jpa query returns previous records. Have I done something wrong?