Kiril,
You can't cast result of selecting 2 fields which is an Object[] to your entity.
Some vendors (way beyond the spec because it means tracking down loaded fields)
may support partial select of an entity, but you need to read their
documentation on how to achieve that. You can also construct a DAO using NEW
construct in the select clause that will include only needed information.
Regards,
-marina
Kiril Minanov wrote:
> Hi,
>
> This is an example in which I am tring so expolain my problem.
> What i want to do is take only some of the fields fromquery, not the
> entire object (List of objects), because my table is very beig and it
> has many foreign keys to other tables
> and if I take the all table it takes a lot of memmory and the query is
> very slow.
> But whenever I try to take the resut I get a casting error
>
> How can I get a reult set like with standard java
>
>
> EntityManager em = Menu.emf.createEntityManager();
>
> String query_string =
> "SELECT" +
> "t.column_1" +
> " t.column_2" +
> "FROM " +
> " Table t ";
>
> Query query = em.createQuery(query_string);
>
> List<TableClass> results =
> (List<TableClass>)query.getResultList() //This is where the problem occurs
>
>
>
> --
> minance