[ 
https://issues.apache.org/jira/browse/OPENJPA-2488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18045720#comment-18045720
 ] 

Pawel Veselov commented on OPENJPA-2488:
----------------------------------------

FWIW, I fixed this with that: 
https://github.com/veselov/openjpa/commit/21092e2791ae1974ea075225307b0464bfef547e

This was annoying because even selecting sum(1) from table (at least using 
Criteria API) doesn't work because of this, and PG has some rotten ideas about 
query plans that have table.id in them to boot.

> select with fixed column doesn't run
> ------------------------------------
>
>                 Key: OPENJPA-2488
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2488
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.2.2
>            Reporter: Daniele Pirola
>            Priority: Major
>
> 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;
>     }
> }



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to