cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Manuel Mata <manuel_mata_ru...@yahoo.es>
Subject Re: How can i acces to Class from a Class name ?
Date Tue, 06 Feb 2007 17:51:22 GMT
> 
> Instead you could also use
> 
> var perfil = hs.createQuery("mypackage.MyClass as
> myClass where id = " + 
> id).uniqueResult();
> 
> Note that in Java you would normally do something
> like
> 
> MyClass myClass = (MyClass)
> hs.createQuery("mypackage.MyClass as myClass 
> where id = " + id).uniqueResult();
> 
> This is required since createQuery returns an Object
> and not a MyClass. 
> This could mean that you would need another class
> that in turn would 
> query the database.
> 

I used this and it works, but i think to access the
first item in the list is not very elegant ...

var perfil = getById("mypackage.MyClass", id);

function getById(c, id){
  return hs.find("from " + c + " where id = " +
id).get(0);
}


		
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message