-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to Map a View?
PostPosted: Thu Apr 03, 2008 10:10 am 
Newbie

Joined: Wed Feb 13, 2008 6:38 am
Posts: 5
Location: Germany - Leipzig
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.