2 Replies Latest reply: Jul 13, 2012 8:17 AM by Diego Gusava RSS

Seam 2.2.2.Final new operator in EJBQL

Diego Gusava Newbie

I am having a problem with EntityQuery from Seam 2.2.2.Final, I can´t use the "new" operator in EJBQL,

"Select new com.ej.Prest(prest.id, prest.name) from Prest prest"

Someone resolved this?

  • 1. Re: Seam 2.2.2.Final new operator in EJBQL
    Petrus Russello Newbie

    Hi Diego,

    if you use JPA as persistence provider you have to simply write your EJBQL query like this:

    select p from Prest p

    to select a Prest entity from your DB, if Prest is really the name of the java class annotated with @Entity.

     

    The new operator isn't a right EJBQL operator.

  • 2. Re: Seam 2.2.2.Final new operator in EJBQL
    Diego Gusava Newbie

    I have resolved this already

     

    I change the subject pattern

     

    from this

     

    private static final Pattern SUBJECT_PATTERN = Pattern.compile("^select\\s+(\\w+(?:\\s*\\.\\s*\\w+)*?)(?:\\s*,\\s*(\\w+(?:\\s*\\.\\s*\\w+)*?))*?\\s+from", Pattern.CASE_INSENSITIVE);

     

    to this

     

    private static final Pattern SUBJECT_PATTERN =Pattern.compile("[^.*]from\\s+[\\.\\w]+\\s+(\\w+)[^.*]?",Pattern.CASE_INSENSITIVE);

     

    now .. I can use the "new" operator.

     

    Thanks