cvinayak wrote:
As long as the objects are created in the same session that executes the query, the objects should get persisted.
Exactly, but the table in the database remains empty.
cvinayak wrote:
Can you post the code snippet where you are facing this problem?
Fetching the list by:
      List rels = session.createSQLQuery(
          "select " +
          "est.stamklasseidfk AS {FagholdxStamklasse.stamklasseId}, " +
          "fxe.fagholdidfk AS {FagholdxStamklasse.fagholdId}, " +
          "count(UNIQUE fxe.elevidfk) AS {FagholdxStamklasse.gyldig} " +
          "from " +
          "elevxstamklasse est " +
          "LEFT JOIN fagholdxelev fxe on est.elevidfk = fxe.elevidfk " +
          "group by est.stamklasseidfk, fxe.fagholdidfk")
          .addEntity("FagholdxStamklasse", FagholdxStamklasse.class)
          .list();
I guess this somehow should be sufficient to persist the "FagholdxStamklasse"-objects , but they do not get persisted.
Maybe the explanation is pretty simple. The objects have just been loaded - albeit via a query - and hibernate assumes that the objects are persisted since the values retreived are from the database.
The caveat is that the objects haven't been loaded as hibernate assumes.
Or am I complete off here?
/Tage