You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Clément Maignien <c....@edic-syliance.com> on 2005/08/11 10:11:19 UTC

RE : Datatable and Hibernate query

Hi,
Your code seems to be good ... But having the error code would be easier to solve your problem.
Maybe you can check the type of database datas your are getting so they can't be outputed in the t:dataTable.
Other thing, you seems to use the HibernateTemplate of the Spring Framework, but I advise you to use an hibernateSession object (get it with org.springframework.orm.hibernate3.SessionFactoryUtils class) instead. This way, you will be able to use all the hibernate API (Criteria, Query, Collection, etc). The HibernateTemplate is a good solution for only very simple query.

Hope this helps ;)
Clément.

-----Message d'origine-----
De : Johannes Hiemer [mailto:jhiemer@web.de] 
Envoyé : jeudi 11 août 2005 09:19
À : users@myfaces.apache.org
Objet : Datatable and Hibernate query



Hi,
I am getting into trouble with a bit adavanced hibernate query that I want to show up in a datatable. That is my hibernate query:
	public List getRequests() {
		return getHibernateTemplate()
				.find("from Request request, Customer customer, Employee employee, System system,"
			 + " Systemerror systemerror, Customee customee WHERE request.Rcustomer = customer.Cid"
			 + " AND request.Rscheduler = employee.Eid AND request.Rfieldengineer = employee.Eid " 
			 + " AND request.Rtag = system.Sid AND request.Rerror = systemerror.Seid AND" 
			 + " request.Rcustomee = customee.Cid");
	}

And it returns the following structure
@see attached picture.

So I am loading the query just the normal way I always to into a list
@SuppressWarnings("unchecked")
	private void populateRequestBean() {
		request = getRequestManager().getRequests();
	}

Now I try to get the values of the list in my datatable as an output. I tried many ways, but I did not get it till yet.

<x:dataTable id="data" 
			var="request" value="#{listrequestsSpringBean.request}">
			<h:column>
				<f:facet name="header">
					<h:outputText value="#{bundle.listrequestsRID}" />
				</f:facet>
				<h:outputText value="#{request.object.request.rid}" />
			</h:column>

Is the way I am doing right or wrong?
Did anyone solve a similiar problem?

I hope anyone can help me.

Thanks a lot

Regards Johannes ______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS! Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193


Re: RE : Datatable and Hibernate query

Posted by Martin Marinschek <ma...@gmail.com>.
wild shot into the blue:

try to rename the variable 'request' to something else...

regards,

Martin

On 8/11/05, Clément Maignien <c....@edic-syliance.com> wrote:
> 
> Hi,
> Your code seems to be good ... But having the error code would be easier 
> to solve your problem.
> Maybe you can check the type of database datas your are getting so they 
> can't be outputed in the t:dataTable.
> Other thing, you seems to use the HibernateTemplate of the Spring 
> Framework, but I advise you to use an hibernateSession object (get it with 
> org.springframework.orm.hibernate3.SessionFactoryUtils class) instead. 
> This way, you will be able to use all the hibernate API (Criteria, Query, 
> Collection, etc). The HibernateTemplate is a good solution for only very 
> simple query.
> 
> Hope this helps ;)
> Clément.
> 
> -----Message d'origine-----
> De : Johannes Hiemer [mailto:jhiemer@web.de]
> Envoyé : jeudi 11 août 2005 09:19
> À : users@myfaces.apache.org
> Objet : Datatable and Hibernate query
> 
> 
> 
> Hi,
> I am getting into trouble with a bit adavanced hibernate query that I want 
> to show up in a datatable. That is my hibernate query:
> public List getRequests() {
> return getHibernateTemplate()
> .find("from Request request, Customer customer, Employee employee, System 
> system,"
> + " Systemerror systemerror, Customee customee WHERE request.Rcustomer = 
> customer.Cid"
> + " AND request.Rscheduler = employee.Eid AND request.Rfieldengineer = 
> employee.Eid "
> + " AND request.Rtag = system.Sid AND request.Rerror = systemerror.SeidAND"
> + " request.Rcustomee = customee.Cid");
> }
> 
> And it returns the following structure
> @see attached picture.
> 
> So I am loading the query just the normal way I always to into a list
> @SuppressWarnings("unchecked")
> private void populateRequestBean() {
> request = getRequestManager().getRequests();
> }
> 
> Now I try to get the values of the list in my datatable as an output. I 
> tried many ways, but I did not get it till yet.
> 
> <x:dataTable id="data"
> var="request" value="#{listrequestsSpringBean.request}">
> <h:column>
> <f:facet name="header">
> <h:outputText value="#{bundle.listrequestsRID}" />
> </f:facet>
> <h:outputText value="#{request.object.request.rid}" />
> </h:column>
> 
> Is the way I am doing right or wrong?
> Did anyone solve a similiar problem?
> 
> I hope anyone can help me.
> 
> Thanks a lot
> 
> Regards Johannes 
> ______________________________________________________________
> Verschicken Sie romantische, coole und witzige Bilder per SMS! Jetzt bei 
> WEB.DE <http://WEB.DE> FreeMail: http://f.web.de/?mc=021193
> 
>