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

select with fixed column doesn't run

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.2.2
    • None
    • None
    • None

    Description

      Suppose to have a mapped Entity named Dual and want to retrieve the sysdate from the db.
      If you try this code:

      Timestamp ts;

      CriteriaBuilder builder = entityManager.getCriteriaBuilder();
      CriteriaQuery<Timestamp> criteria = builder.createQuery(Timestamp.class);
      criteria.select(builder.currentTimestamp());
      criteria.from(Dual.class);
      ts =entityManager.createQuery(criteria).setMaxResults(1).getSingleResult();

      openjpa build a query like this:
      SELECT CURRENT_TIMESTAMP FROM WHERE ROWNUM <= ?

      without the table Dual specified.
      This is the Dual class but the error always happens with other real table:

      @Entity
      @Table(name = "DUAL")
      @Access(AccessType.FIELD)
      public class Dual implements Serializable {
      @Id
      @Column(name = "DATE_VALUE")
      @Temporal(TemporalType.TIMESTAMP)
      private Date date;

      public Date getDate()

      { return date; }

      public void setDate(Date date)

      { this.date = date; }

      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            daniele.pirola@icteam.it Daniele Pirola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: