Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-1903

Some queries only work the first time they are executed


    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.2.0
    • Component/s: query
    • Labels:


      I have a problem in my application where a query that sometimes returns data and sometimes not.

      I have reduced it to the code as much as I could into an Eclipse project available at http://ubuntuone.com/p/S9n/

      This happens with OpenJPA 2.0.1 as well as the daily snapshot from 2010-12-05 and an out-of-process Derby database.

      Basically I have two Entities which both use multiple Ids to produce the Primary Key, "Preis" contains a foreign key on "Website":

      public class Website {
      private String mandant;

      private String name;

      public class Preis {
      @ManyToOne(cascade = CascadeType.MERGE)
      private Website website;

      private String datum;

      I use the following to set up a website and a Preis:


      Website website = em.merge(new Website("Mandant", "Website"));

      em.merge(new Preis(website, DATUM));


      Afterwards, if I run the query as follows:

      TypedQuery<Preis> q = em.createQuery(
      "select m from Preis m " +
      "where m.website.name = :website ", Preis.class);
      q.setParameter("website", website.getName());

      this query works all the time, note that it uses website.name for matching, not the full Website-object.

      However if I put the query as

      TypedQuery<Preis> q = em.createQuery(
      "select m from Preis m " +
      "where m.website = :website ", Preis.class);
      q.setParameter("website", website);

      it only works ONCE and then does not return any results any more!! See testcase DataAccessVerifyTest for details.

      Discussion on the mailinglist seems to indicate that this is a bug.


          Issue Links



              • Assignee:
                ppoddar@apache.org Pinaki Poddar
                centic Dominik Stadler (Inactive)
              • Votes:
                0 Vote for this issue
                0 Start watching this issue


                • Created: