-->
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.  [ 7 posts ] 
Author Message
 Post subject: No persister for error with createSQLQuery
PostPosted: Tue Sep 07, 2004 11:05 pm 
Newbie

Joined: Tue Jun 08, 2004 11:41 am
Posts: 10
Location: Fortaleza/Brazil
Code:
String qry = "select livro.cd_livro as {r.codigoLivro},  " +
                   "       livro.nm_livro as {r.nomeLivro},      " +
                   "       sum( vendas.qt_livros ) as {r.qtde} " +
                   "from vendas inner join livro " +
                   "      on ( vendas.cd_livro = livro.cd_livro ) " +
                   "group by livro.cd_livro, livro.nm_livro " +
                   "order by sum( vendas.qt_livros ) DESC ";
         ;
         
         top10 = session.createSQLQuery( qry, "r", bean.Resultado.class ).list();


The code above produces the "[0] No persister for: bean.Resultado" error.

How can I resolve this? The resultado is a simple bean like this:

Code:
public class Resultado {

   public int      codigoLivro;
   public String nomeLivro;
   public int      qtde;

   
   public int getCodigoLivro() {
      return codigoLivro;
   }
   public void setCodigoLivro(int codigoLivro) {
      this.codigoLivro = codigoLivro;
   }
   public String getNomeLivro() {
      return nomeLivro;
   }
   public void setNomeLivro(String nomeLivro) {
      this.nomeLivro = nomeLivro;
   }
   public int getQtde() {
      return qtde;
   }
   public void setQtde(int qtde) {
      this.qtde = qtde;
   }
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 2:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
as per the documentation the objects loaded by createsqlquery must be entities persistable by Hibernate.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: And about reports?
PostPosted: Wed Sep 08, 2004 5:32 am 
Newbie

Joined: Tue Jun 08, 2004 11:41 am
Posts: 10
Location: Fortaleza/Brazil
max wrote:
as per the documentation the objects loaded by createsqlquery must be entities persistable by Hibernate.


And about reports? I need to only return a value object structure that is util to extract data to my report.

The value object used here is not to be persisted.... They doesn't have a table related. There is only a value object!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 5:47 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Thats what JDBC ResultSet's are for.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 6:01 am 
Newbie

Joined: Tue Jun 08, 2004 11:41 am
Posts: 10
Location: Fortaleza/Brazil
christian wrote:
Thats what JDBC ResultSet's are for.


I don't think so. Hibernate can work for me in this case to map the resultset to a value object. (iBats do that, for example)

Did You need to write SQL queries using Hibernate? Or HQL is sufficient for this kind of thing?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 7:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
HQL is very good to reporting - have you read the query docs ?

You have the possibility to use object queries (select a from A as a where... ", scalar/report queries (like "select a.x, a.y, a.z from A as a where ...") and value object queries (like "select new MyValue(a.x,a.y,a.z) from A as a where...")

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 7:17 am 
Newbie

Joined: Tue Jun 08, 2004 11:41 am
Posts: 10
Location: Fortaleza/Brazil
Max,

I trying to make a stupid query to retrieve the top 10 most sold products with HQL without sucess.

I post this to thread http://forum.hibernate.org/viewtopic.ph ... highlight=

This is the reason because I answer you about the power of HQL...

There is a answer to my question? How can I do that?


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

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.