facebook

hibernate select new

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #298022 Reply

    David
    Member

    I have a multitable SQL that I am running in a SQLQuery, such as:

    SQLQuery query = currentSession().createSQLQuery(sql.toString());
    List confResults = query.list();

    This naturally brings back Object[] but I would like to have my results in a DTO so I can quickly get them out by name. So I changed my SQL to be like this:

    SELECT new myDTO(/*+ rule */ a.field1, a.field2,a.field3, a.field4, b.field1, b.field2 ) FROM tableA a, tableB b WHERE a.id = b.id(+) AND <more parameters here>

    However, when I execute query.list I get the error:
    Caused by: java.sql.SQLException: ORA-00923: FROM keyword not found where expected

    My DTO is just a bean, so I don’t that is it. If I take out the “new myDTO(…)” then it runs, returning Object[].

    Any ideas why this doesn’t work?

    #298035 Reply

    Loyal Water
    Member

    Moving to Off Topic >> Software Development.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: hibernate select new

You must be logged in to post in the forum log in