# Caused by: org.postgresql.util.psqlexception: error: operator does not exist: character varying = bytea

**URL:** <https://talk.openelis-global.org/t/caused-by-org-postgresql-util-psqlexception-error-operator-does-not-exist-character-varying-bytea/787>\
**Category:** Uncategorized\
**Created:** [June 22, 2024, 6:04pm UTC](https://talk.openelis-global.org/t/caused-by-org-postgresql-util-psqlexception-error-operator-does-not-exist-character-varying-bytea/787 "2024-06-22T18:04:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mherman22](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.openelis-global.org/mherman22/32/92_2.png) [@mherman22](https://talk.openelis-global.org/u/mherman22)\
**Post date:** [June 22, 2024, 6:04pm UTC](https://talk.openelis-global.org/t/caused-by-org-postgresql-util-psqlexception-error-operator-does-not-exist-character-varying-bytea/787/1 "2024-06-22T18:04:20Z")

</div>

Hey, i am working on [Create an Event Listener that listens to patient creation by mherman22 · Pull Request #1065 · I-TECH-UW/OpenELIS-Global-2 · GitHub](https://github.com/I-TECH-UW/OpenELIS-Global-2/pull/1065) and i have had to do alot of changes especially with how beans are being created with an aim of making the existing tests pass and get the app up and running for me to test my changes.

I am getting an error in the terminal when i start the app, find the logs at [Ubuntu Pastebin](https://pastebin.ubuntu.com/p/y8wnFTv4t3/). I have written a test case and it passes but for some reason i am yet to establish, the enum value is sent as **bytea** and not as a string as it should.

I have even gone ahead to use type safe enabled by the jpa criteria api as seen below but all in vain:

```auto
  public NotificationPayloadTemplate getSystemDefaultPayloadTemplateForType(NotificationPayloadType type) {
    List<NotificationPayloadTemplate> data;
    try {
      CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
      CriteriaQuery<NotificationPayloadTemplate> criteriaQuery = criteriaBuilder.createQuery(NotificationPayloadTemplate.class);
      Root<NotificationPayloadTemplate> root = criteriaQuery.from(NotificationPayloadTemplate.class);
      criteriaQuery.where(criteriaBuilder.equal(root.get("type"), type));
      criteriaQuery.orderBy(criteriaBuilder.asc(root.get("id")));
      TypedQuery<NotificationPayloadTemplate> query = entityManager.createQuery(criteriaQuery);
      query.setMaxResults(1);
      data = query.getResultList();
    } catch (RuntimeException e) {
      LogEvent.logError(e);
      throw new LIMSRuntimeException("Error in getSystemDefaultPayloadTemplateForType", e);
    }

    return data.isEmpty() ? null : data.get(0);
  }

```

cc: @Moses_Mutesasira @reagan @sharif [@everyone](https://talk.openelis-global.org/groups/everyone)

---

<div class="post-metadata">

**Author:** ![Moses\_Mutesasira](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.openelis-global.org/moses_mutesasira/32/72_2.png) [@Moses\_Mutesasira](https://talk.openelis-global.org/u/Moses_Mutesasira)\
**Post date:** [June 24, 2024, 7:00am UTC](https://talk.openelis-global.org/t/caused-by-org-postgresql-util-psqlexception-error-operator-does-not-exist-character-varying-bytea/787/2 "2024-06-24T07:00:36Z")

</div>

```auto
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying = bytea
openelisglobal-webapp | Hint: No operator matches the given name and argument types. You might need to add explicit type casts.

```

Its usually caused by hibernate failing to determine the arg type in a Hibernate query

Its most probably caused by this [change](https://github.com/I-TECH-UW/OpenELIS-Global-2/pull/1065/files#diff-6f29f1479ee55379c19c9a8f6941b7e91e0852c56a94975204dc171987df5a83R33)

`query.setParameter("type", type.name());` but you changed it to `query.setParameter("type", type);`

In the DB type is saved as a String , so you should convert the ENUM to a string value when querying with hibernate
