spring-projects / spring-projects/spring-modulith

MySQL event publication registry schema leads to SQLException

Open
#94 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.2k
Forks
222
PR merge metrics
No merged PRs in 30d

Description

Hi,

I have tried to work with TransactionalEventListener but always received the SQLException Incorrect string value: '\xA7IL\x9D\xC2\x88...' for column 'id' at row 1 whenever the handler received an event.

I am working with MySQL and initialized my schema with the following command that can be found in the documentation (slightly adapted because I use the JPA starter).

create table jpa_event_publication (
    id VARCHAR(36) not null, 
    completion_date TIMESTAMP(6), 
    event_type varchar(512), listener_id varchar(512), 
    publication_date TIMESTAMP(6), 
    serialized_event varchar(4000), 
    primary key (id)
);

After digging deeper into the stack trace, I discovered that the prepared statement looks like this:

insert into jpa_event_publication (completion_date, event_type, listener_id, publication_date, serialized_event, id) values (..., x'dfa3fa1818e447c59e214abf60964755');

The x before the actual id is not a typo and actually causes the error.

I was able to resolve the error by changing the type of the id column in the database to BINARY(16) as is suggested here.

create table jpa_event_publication (
    id BINARY(16) not null, 
    completion_date TIMESTAMP(6), 
    event_type varchar(512), listener_id varchar(512), 
    publication_date TIMESTAMP(6), 
    serialized_event varchar(4000), 
    primary key (id)
);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository file or test is named. Start by comparing the documented MySQL event publication schema with the JPA event publication persistence path and the prepared insert shown in the report. Done means the documented schema and generated identifier representation are compatible, with the TransactionalEventListener no longer producing the SQLException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mysql
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.