SQL Query casting objects
I have an SQL query to do a full-text search on my database: String sql = "SELECT * FROM Items WHERE MATCH (title, description) AGAINST ('" + searchText + "');"; List items = session.createSQLQuery(sql).list(); When I execute it, it returns a list with the rows it found as a result. Each row is actually an "Item" object, but since this is an SQL query, the result is an array of Objects. Is there a way to cast it to an "Item" object without having to manually go through each of the columns it returns? The same way an HQL automatically casts the results: List items = (List) session.createQuery( ... ); I had no luck finding out how to implement sql MATCH and AGAINST using HQL. Does anyone know a solution to this issue? Thanks! - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: SQL Query casting objects
SQLQuery.addEntity(Class entityClass).list() http://docs.jboss.org/hibernate/core/3.3/api/org/hibernate/class-use/SQLQuery.html -Original Message- From: Henrique Boregio [mailto:hbore...@gmail.com] Sent: Friday, December 10, 2010 3:40 AM To: users@wicket.apache.org Subject: SQL Query casting objects I have an SQL query to do a full-text search on my database: String sql = "SELECT * FROM Items WHERE MATCH (title, description) AGAINST ('" + searchText + "');"; List items = session.createSQLQuery(sql).list(); When I execute it, it returns a list with the rows it found as a result. Each row is actually an "Item" object, but since this is an SQL query, the result is an array of Objects. Is there a way to cast it to an "Item" object without having to manually go through each of the columns it returns? The same way an HQL automatically casts the results: List items = (List) session.createQuery( ... ); I had no luck finding out how to implement sql MATCH and AGAINST using HQL. Does anyone know a solution to this issue? Thanks! - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: SQL Query casting objects
Thanks, I'll give it a shot! On Thu, Dec 9, 2010 at 11:39 PM, Henrique Boregio wrote: > I have an SQL query to do a full-text search on my database: > > String sql = "SELECT * FROM Items WHERE MATCH (title, description) > AGAINST ('" + searchText + "');"; > List items = session.createSQLQuery(sql).list(); > > When I execute it, it returns a list with the rows it found as a result. > Each row is actually an "Item" object, but since this is an SQL query, > the result is an array of Objects. > Is there a way to cast it to an "Item" object without having to > manually go through each of the columns it returns? > > The same way an HQL automatically casts the results: > List items = (List) session.createQuery( ... ); > > I had no luck finding out how to implement sql MATCH and AGAINST using HQL. > > Does anyone know a solution to this issue? Thanks! > -- Henrique Boregio - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: SQL Query casting objects
SQL is very good, if you want to export data from sql, you can use Free DataExport Component~~ 100% Free~ More here: http://www.e-iceblue.com/Introduce/free-dataexport-component.html http://www.e-iceblue.com/Introduce/free-dataexport-component.html -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/SQL-Query-casting-objects-tp3081312p3224855.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org