Hello,
I try to map my Postgresql DB.
I have a Table
Code:
@Entity
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
@SequenceGenerator(name = "notes_seq", sequenceName = "notes_id_seq")
@Table(name = "Notes", schema = "public", uniqueConstraints = {})
public class Notes implements java.io.Serializable {
and an View
Code:
@Entity
@Table(name = "countview", schema = "public")
@Cache(usage=CacheConcurrencyStrategy.NONE)
public class Countview implements java.io.Serializable {
the View is defined with this Statement
Code:
CREATE OR REPLACE VIEW countview AS
SELECT n.postkorb, count(*) AS anzahl
FROM notes n
GROUP BY n.postkorb;
when there come a new Insert in the "Notes" Table,
the View Result with an EntityManager is even the same
before the Insert in the Notes Table.
Code:
public List<Countview> findAll() {
try {
String queryString = "select model from Countview model order by postkorb desc";
EntityManager em = getEntityManager();
List<Countview> ln = em.createQuery(queryString).getResultList();
return ln;
} catch (RuntimeException re) {
log.error("find all failed", re);
}
}
I have disable all Caches.
How can i get the correct value by selecting from a View?
I there an Annotion to mark an Entity as an View?
Thanks
Johannes