-->
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.  [ 6 posts ] 
Author Message
 Post subject: How to access class properties in select w/ several classes
PostPosted: Fri Nov 18, 2005 9:51 am 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
Hibernate version: 3.0

Hello everyone. I have a doubt.

I have the following SQL:

Code:
                   Query select = session.createQuery("from OrdemItens oi," +
                            " FichaTecnica f,  " +
                            "MPFichaTecnica mpf  " +
                            " where oi.ordemDeProducao.status <> 1 " +
                            " and oi.codigoLote = null " +
                            " and f.produto.produto = oi.produto.produto" +
                            " and mpf.fichaTecnica.fichaTecnica = f.fichaTecnica" +
                            " and mpf.principal = 1" +
                            " and mpf.materiaPrima.materia = ?" +
                            " order by oi.ordemDeProducao.numeroOrdem");


This query is executed successfully. I can see it on the logs, it apparently returns what I believe it should. The problem is that I'm not being able to access the classes properties.

I was used to do something like "from Classe a where a.blabla =2". Then, I would easily access it in my jsp, in a c:forEach, with a element.myResultList. But with my select, when I do the same I get the error:
Code:
javax.servlet.jsp.el.ELException: The "." operator was supplied with an index value of type "java.lang.String" to be applied to a List or array, but that value cannot be converted to an integer.


I wanna iterate through the OrdemItens in the List, but I suppose it does not return me a OrdemItens List, and I don't really know what it returns and how I do to access what I want.
The thing is, I only need the other classes names there to make the joins, otherwise OrdemItens would be enough. But since that is what I have, how do I do to access what I want?

Thanks very much

_________________
Don't forget to rate if the post helped!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 18, 2005 10:33 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
your new HQL (not SQL) returns a list of Object[]'s and not just a list of Object's.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 18, 2005 11:47 am 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
Max,
I didn't really get what you mean.

_________________
Don't forget to rate if the post helped!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 18, 2005 1:40 pm 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
How do I do it for it to return only the OrdemItens object?

_________________
Don't forget to rate if the post helped!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 18, 2005 1:44 pm 
Beginner
Beginner

Joined: Tue Feb 01, 2005 5:26 pm
Posts: 24
Location: dallas
you can specify select in your HQL.

Code:
Query select = session.createQuery("select oi from OrdemItens oi," +
                            " FichaTecnica f,  " +
                            "MPFichaTecnica mpf  " +
                            " where oi.ordemDeProducao.status <> 1 " +
                            " and oi.codigoLote = null " +
                            " and f.produto.produto = oi.produto.produto" +
                            " and mpf.fichaTecnica.fichaTecnica = f.fichaTecnica" +
                            " and mpf.principal = 1" +
                            " and mpf.materiaPrima.materia = ?" +
                            " order by oi.ordemDeProducao.numeroOrdem");



hopw this post helps, dont forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 18, 2005 2:04 pm 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
sreepraveen_2000 wrote:
you can specify select in your HQL.

Code:
Query select = session.createQuery("select oi from OrdemItens oi," +
                            " FichaTecnica f,  " +
                            "MPFichaTecnica mpf  " +
                            " where oi.ordemDeProducao.status <> 1 " +
                            " and oi.codigoLote = null " +
                            " and f.produto.produto = oi.produto.produto" +
                            " and mpf.fichaTecnica.fichaTecnica = f.fichaTecnica" +
                            " and mpf.principal = 1" +
                            " and mpf.materiaPrima.materia = ?" +
                            " order by oi.ordemDeProducao.numeroOrdem");



hopw this post helps, dont forget to rate.


So obvious! Thank you very much.

It's rated :)

_________________
Don't forget to rate if the post helped!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.