You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Henrique Boregio <hb...@gmail.com> on 2010/12/10 03:39:57 UTC

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<Item> items = (List<Item>) 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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: SQL Query casting objects

Posted by ice123456 <WS...@gmail.com>.
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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: SQL Query casting objects

Posted by "Bodis, Jerome" <bo...@uni-mainz.de>.
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:hboregio@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<Item> items = (List<Item>) 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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: SQL Query casting objects

Posted by Henrique Boregio <hb...@gmail.com>.
Thanks, I'll give it a shot!

On Thu, Dec 9, 2010 at 11:39 PM, Henrique Boregio <hb...@gmail.com> 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<Item> items = (List<Item>) 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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org