You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by "Leonardo K. Shikida" <sh...@gmail.com> on 2015/02/18 09:44:16 UTC

Fwd: strange qbe query for tomee 1.6.0 stable (OpenJPA 2.3.0-nonfinal-1540826)

Hi

I have a query like this

    public List<E> qbe(E example) {
        OpenJPACriteriaBuilder cb = (OpenJPACriteriaBuilder)
entityManager.getCriteriaBuilder();
        CriteriaQuery<E> q = cb.createQuery(clazz);
        Root<E> entity = q.from(clazz);

        q.where(cb.qbe(entity, example)); // query by example
        q.select(entity);

        TypedQuery<E> tq = entityManager.createQuery(q);
        return tq.getResultList();
    }

for entities like this

@Entity
@Table(name="APPUSER",uniqueConstraints=@UniqueConstraint(columnNames={"username"}))
public class User implements Serializable{
    /**
     *
     */
    private static final long serialVersionUID = 4411272750939441365L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
(...)

and this

@Entity
public class PasswordRotationJob implements Serializable{

(...)
    @ManyToOne
    @JoinColumn(name="userId")
    private User submitter;

The QBE query seems to assume a wrong column name

Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ORA-00904:
"T1"."USERID": invalid identifier
 {prepstmnt 1347119244 SELECT t0.id,(...), t1.id, (...), t2.id, (...)
FROM PasswordRotationJob
t0, APPUSER t1, (...) WHERE (...) AND t0.userId = t1.userId(+) (...)}
[code=904, state=42000]

Is this a bug? If so, was it addressed in TomEE 1.7.1?

TIA

Leo

Re: strange qbe query for tomee 1.6.0 stable (OpenJPA 2.3.0-nonfinal-1540826)

Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
actually, I thought joincolumn here would be the FK name, not the
referenced PK name in the other table

[]

Leo

On Wed, Feb 18, 2015 at 7:01 AM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> Hi
>
> not sure it is fixed but wonder if your joincolumn shouldnt be id?
>
>
> Romain Manni-Bucau
> @rmannibucau
> http://www.tomitribe.com
> http://rmannibucau.wordpress.com
> https://github.com/rmannibucau
>
>
> 2015-02-18 9:44 GMT+01:00 Leonardo K. Shikida <sh...@gmail.com>:
> > Hi
> >
> > I have a query like this
> >
> >     public List<E> qbe(E example) {
> >         OpenJPACriteriaBuilder cb = (OpenJPACriteriaBuilder)
> > entityManager.getCriteriaBuilder();
> >         CriteriaQuery<E> q = cb.createQuery(clazz);
> >         Root<E> entity = q.from(clazz);
> >
> >         q.where(cb.qbe(entity, example)); // query by example
> >         q.select(entity);
> >
> >         TypedQuery<E> tq = entityManager.createQuery(q);
> >         return tq.getResultList();
> >     }
> >
> > for entities like this
> >
> > @Entity
> >
> @Table(name="APPUSER",uniqueConstraints=@UniqueConstraint(columnNames={"username"}))
> > public class User implements Serializable{
> >     /**
> >      *
> >      */
> >     private static final long serialVersionUID = 4411272750939441365L;
> >
> >     @Id
> >     @GeneratedValue(strategy = GenerationType.AUTO)
> >     private Long id;
> > (...)
> >
> > and this
> >
> > @Entity
> > public class PasswordRotationJob implements Serializable{
> >
> > (...)
> >     @ManyToOne
> >     @JoinColumn(name="userId")
> >     private User submitter;
> >
> > The QBE query seems to assume a wrong column name
> >
> > Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ORA-00904:
> > "T1"."USERID": invalid identifier
> >  {prepstmnt 1347119244 SELECT t0.id,(...), t1.id, (...), t2.id, (...)
> > FROM PasswordRotationJob
> > t0, APPUSER t1, (...) WHERE (...) AND t0.userId = t1.userId(+) (...)}
> > [code=904, state=42000]
> >
> > Is this a bug? If so, was it addressed in TomEE 1.7.1?
> >
> > TIA
> >
> > Leo
>

Re: strange qbe query for tomee 1.6.0 stable (OpenJPA 2.3.0-nonfinal-1540826)

Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
damn.

it could be...

[]

Leo

On Wed, Feb 18, 2015 at 7:01 AM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> Hi
>
> not sure it is fixed but wonder if your joincolumn shouldnt be id?
>
>
> Romain Manni-Bucau
> @rmannibucau
> http://www.tomitribe.com
> http://rmannibucau.wordpress.com
> https://github.com/rmannibucau
>
>
> 2015-02-18 9:44 GMT+01:00 Leonardo K. Shikida <sh...@gmail.com>:
> > Hi
> >
> > I have a query like this
> >
> >     public List<E> qbe(E example) {
> >         OpenJPACriteriaBuilder cb = (OpenJPACriteriaBuilder)
> > entityManager.getCriteriaBuilder();
> >         CriteriaQuery<E> q = cb.createQuery(clazz);
> >         Root<E> entity = q.from(clazz);
> >
> >         q.where(cb.qbe(entity, example)); // query by example
> >         q.select(entity);
> >
> >         TypedQuery<E> tq = entityManager.createQuery(q);
> >         return tq.getResultList();
> >     }
> >
> > for entities like this
> >
> > @Entity
> >
> @Table(name="APPUSER",uniqueConstraints=@UniqueConstraint(columnNames={"username"}))
> > public class User implements Serializable{
> >     /**
> >      *
> >      */
> >     private static final long serialVersionUID = 4411272750939441365L;
> >
> >     @Id
> >     @GeneratedValue(strategy = GenerationType.AUTO)
> >     private Long id;
> > (...)
> >
> > and this
> >
> > @Entity
> > public class PasswordRotationJob implements Serializable{
> >
> > (...)
> >     @ManyToOne
> >     @JoinColumn(name="userId")
> >     private User submitter;
> >
> > The QBE query seems to assume a wrong column name
> >
> > Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ORA-00904:
> > "T1"."USERID": invalid identifier
> >  {prepstmnt 1347119244 SELECT t0.id,(...), t1.id, (...), t2.id, (...)
> > FROM PasswordRotationJob
> > t0, APPUSER t1, (...) WHERE (...) AND t0.userId = t1.userId(+) (...)}
> > [code=904, state=42000]
> >
> > Is this a bug? If so, was it addressed in TomEE 1.7.1?
> >
> > TIA
> >
> > Leo
>

Re: strange qbe query for tomee 1.6.0 stable (OpenJPA 2.3.0-nonfinal-1540826)

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

not sure it is fixed but wonder if your joincolumn shouldnt be id?


Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau


2015-02-18 9:44 GMT+01:00 Leonardo K. Shikida <sh...@gmail.com>:
> Hi
>
> I have a query like this
>
>     public List<E> qbe(E example) {
>         OpenJPACriteriaBuilder cb = (OpenJPACriteriaBuilder)
> entityManager.getCriteriaBuilder();
>         CriteriaQuery<E> q = cb.createQuery(clazz);
>         Root<E> entity = q.from(clazz);
>
>         q.where(cb.qbe(entity, example)); // query by example
>         q.select(entity);
>
>         TypedQuery<E> tq = entityManager.createQuery(q);
>         return tq.getResultList();
>     }
>
> for entities like this
>
> @Entity
> @Table(name="APPUSER",uniqueConstraints=@UniqueConstraint(columnNames={"username"}))
> public class User implements Serializable{
>     /**
>      *
>      */
>     private static final long serialVersionUID = 4411272750939441365L;
>
>     @Id
>     @GeneratedValue(strategy = GenerationType.AUTO)
>     private Long id;
> (...)
>
> and this
>
> @Entity
> public class PasswordRotationJob implements Serializable{
>
> (...)
>     @ManyToOne
>     @JoinColumn(name="userId")
>     private User submitter;
>
> The QBE query seems to assume a wrong column name
>
> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ORA-00904:
> "T1"."USERID": invalid identifier
>  {prepstmnt 1347119244 SELECT t0.id,(...), t1.id, (...), t2.id, (...)
> FROM PasswordRotationJob
> t0, APPUSER t1, (...) WHERE (...) AND t0.userId = t1.userId(+) (...)}
> [code=904, state=42000]
>
> Is this a bug? If so, was it addressed in TomEE 1.7.1?
>
> TIA
>
> Leo