openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Glenn Silverman (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OPENJPA-2426) LIKE operator fails with Postgresql v 9.1
Date Fri, 06 Sep 2013 15:36:54 GMT

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

Glenn Silverman commented on OPENJPA-2426:
------------------------------------------

I'm sorry for the misunderstanding. It seems when I mix opoenjpa with Postgresql 9.1, and
run this query:

SELECT p FROM Patient p where p.firstname like :firstname

I get this error:

Exception: <openjpa-2.2.2-r422266:1468616 fatal general error>
> org.apache.openjpa.persistence.PersistenceException: ERROR: 
> unterminated quoted string at or near "'\')"
>    Position: 841 {prepstmnt 1174610866 SELECT t0.patientid, t0.active, 
> t0.addedat, t0.address1, t0.firstname,... WHERE (t0.firstname LIKE ? 
> ESCAPE '\')} [code=0, state=42601]

I don't get an error when I use a different JPA implementation, such as hibernate. I don't
want to switch from openjpa if I don't have to.

Now, if I replace the LIKE operator with =, the query works fine.
                
> LIKE operator fails with Postgresql v 9.1
> -----------------------------------------
>
>                 Key: OPENJPA-2426
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2426
>             Project: OpenJPA
>          Issue Type: Question
>          Components: jpa
>    Affects Versions: 2.2.2
>         Environment: Apache Karaf v 2.3.2 and Aries JPA
>            Reporter: Glenn Silverman
>              Labels: Aries, JPA
>
> I'm getting very discouraged with OpenJPA as it relates to Postgresql v 9.1 and and creating
queries using the LIKE operator.  I know there was an issue a few years back, https://issues.apache.org/jira/browse/OPENJPA-2056,
but I've tried everything mentioned there as a workaround to get a simple query like this
to work:
> Query query = em.createQuery("SELECT p FROM Patient p where p.lastname = :lastname");
> 		query.setParameter("lastname", "Silver");		
> 		
> List<Patient> patients = query.getResultList();
> I've tried different property settings in my persistence.xml:
> <property name="openjpa.jdbc.DBDictionary" value="postgres"/>  
> and this:
> <property name="openjpa.jdbc.DBDictionary" value="postgres(SearchStringEscape=\)"/>

> and even this:
> <property name="openjpa.jdbc.DBDictionary" value="postgresRequiresSearchStringEscapeForLike=false)"/>

> Nothing works. I'm not even convinced Aries JPA, the environment I'm running in under
Karaf, even recognizes these property settings.
> When I use Hibernate as my persistence provider, I don't have this problem.  I don't
want to give up on OpenJPA in my OSGi environment, but I may have to if no one has a solution.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message