1 Reply Latest reply on May 28, 2008 8:48 AM by jsmanger

    Additional field in SELECT of native query changes result.

    jsmanger

      Hello,

      I am using JBOSS 4.2 with a MySql database. I am running a native query through the entity manager (the query is messy but I will post if anybody wants to see all of it). Running the query through the MySQL query browser produces the expected results. However, when running it with the entity manager, adding a field into the select clause changes the result. For example,

      SELECT loan.id, account1.balance
      // rest of nasty query

      loan.id account1.balance
      ...
      177 456.229 (correct result)
      ...

      Select loan.id, account2.balance, account1.balance

      loan.id account2.balance account1.balance
      ...
      177 123.44 123.44 (correct result for account 2, but not for account 1)
      ...

      The queries don't differ in anything except the select statement, and it seems that the wrong values are somehow being overwritten. Has anybody seen something like this before or can you offer some suggestions? Thanks for your help.