Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table event_publication: value too long for type #471

Open
ivanfryda opened this issue Jan 19, 2024 · 2 comments
Open

Table event_publication: value too long for type #471

ivanfryda opened this issue Jan 19, 2024 · 2 comments
Assignees
Labels
in: event publication registry Event publication registry meta: waiting for feedback Waiting for feedback of the original reporter

Comments

@ivanfryda
Copy link

When saving an Event in PostgreSQL I get the following error:

Caused by: org.hibernate.exception.DataException: could not execute statement [ERROR: value too long for type character varying(255)] [insert into event_publication (completion_date,event_type,listener_id,publication_date,serialized_event,id) values (?,?,?,?,?,?)]

So then I forced that column to be of type bytea by creating an orm.xml in META-INF. Then I got this error:

org.hibernate.exception.SQLGrammarException: could not execute statement [ERROR: column "serialized_event" is of type bytea but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 129] [insert into event_publication (completion_date,event_type,listener_id,publication_date,serialized_event,id) values (?,?,?,?,?,?)]

How to solve this?

@odrotbohm odrotbohm self-assigned this Jan 19, 2024
@odrotbohm odrotbohm added in: event publication registry Event publication registry meta: waiting for feedback Waiting for feedback of the original reporter labels Jan 19, 2024
@odrotbohm
Copy link
Member

How do you create the schema for the event publications? We generally recommend to not let a JPA provider create the schema. The JDBC module recommends this for PostgreSQL.

@ivanfryda
Copy link
Author

Exactly, I am letting the JPA provider create the schema. I now fixed it by having it compliant with the documentation as provided with this orm.xml:

<entity-mappings xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm
                                     http://xmlns.jcp.org/xml/ns/persistence/orm_2_2.xsd"
                 version="2.2">
    <package>org.springframework.modulith.events.jpa</package>
    <entity class="JpaEventPublication">
        <attributes>
            <basic name="listenerId">
                <column name="listener_id" column-definition="text"/>
            </basic>
            <basic name="eventType">
                <column name="event_type" column-definition="text"/>
            </basic>
            <basic name="serializedEvent">
                <column name="serialized_event" column-definition="text"/>
            </basic>
        </attributes>
    </entity>
</entity-mappings>

@ivanfryda ivanfryda reopened this Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: event publication registry Event publication registry meta: waiting for feedback Waiting for feedback of the original reporter
Projects
None yet
Development

No branches or pull requests

2 participants