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

oracle error ORA-01461 when persisting entity with special characters in absurdly specific circumstances #35070

Closed
Felk opened this issue Jul 27, 2023 · 6 comments
Labels
area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working

Comments

@Felk
Copy link
Contributor

Felk commented Jul 27, 2023

Describe the bug

In some absurdly specific circumstances, trying to persist an entity containing the string Nêin will cause the following error when connected to an oracle database:

ORA-01461: can bind a LONG value only for insert into a LONG column

This looks more like a hibernate bug than a quarkus bug, but creating a reproducer with quarkus is way easier, because it requires an actual oracle database, which is trivially availabe using dev services.

Let's say we have this entity:

@Entity
@Data
@NoArgsConstructor(access = AccessLevel.PROTECTED) // for JPA
public class MyEntity {
    @Id
    @GeneratedValue
    private Long id;

    @Column
    Boolean someBool;

    @Column
    String someString;

    public MyEntity(Boolean someBool, String someString) {
        this.someBool = someBool;
        this.someString = someString;
    }
}

and a JDBC batch size of at least 2 (e.g. setting quarkus.hibernate-orm.jdbc.statement-batch-size to 2). Then, running this code will result in the aforementioned error:

MyEntity entityOk = new MyEntity(null, null);
MyEntity entityBorked = new MyEntity(true, "Nêin");

entityManager.persist(entityOk);
entityManager.persist(entityBorked);
entityManager.flush(); // ERROR! ORA-01461

The absurd thing isn't even that the error looks completely unrelated, but that these little changes all fix the problem:

  • Using other special characters, e.g. stuff like "äöüßÄÖÜẞ💩"
  • Slightly changing the string's size, e.g. "Nêi" and "Nêin_" both work
  • Using the decomposite unicode normalization "Nêin" (e + 0x0302 "COMBINING CIRCUMFLEX ACCENT")
    instead of the composite form "Nêin" (0x00EA "LATIN SMALL LETTER E WITH CIRCUMFLEX")
  • Not having a JDBC batch size > 1, or flushing in-between the two inserts
  • Changing the order in which the two entities are persisted
  • Removing the random additional nullable boolean field
  • Not having the Boolean be null for one and not-null for the other entity,
    e.g. true->false or false->true makes the test pass
  • not having the first entity's string be null

I have attached a reproducer project: quarkus-nein-reproducer.zip

Output of java -version

OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode, sharing)

Quarkus version or git rev

3.2.2.Final (broken starting with 3.1.0, fine with 3.0.4)

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.2

@Felk Felk added the kind/bug Something isn't working label Jul 27, 2023
@geoand geoand added area/persistence OBSOLETE, DO NOT USE and removed triage/needs-triage labels Jul 28, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Jul 28, 2023

/cc @DavideD (hibernate-reactive), @Sanne (hibernate-orm,hibernate-reactive), @gavinking (hibernate-reactive), @gsmet (hibernate-orm), @mswatosh (db2), @yrodiere (hibernate-orm)

@geoand geoand added the area/hibernate-orm Hibernate ORM label Jul 28, 2023
@marko-bekhta
Copy link
Contributor

hey @Felk
Thanks for reporting the issue. It looks though that the problem goes beyond Quarkus or even Hibernate ORM 😄. See this test I've created here marko-bekhta/hibernate-test-case-templates@663bf6c.

The error happens if you try to do this with a simple prepared statement. It is only reproducible with a combination of com.oracle.database.jdbc:ojdbc11:23.2.0.0 driver and gvenzl/oracle-free:23 Oracle DB. If a previous version of a driver is used (21.10.0.0) it works fine with gvenzl/oracle-free:23 too. Or if the DB image is changed to gvenzl/oracle-xe it works fine with both drivers.

3.2.2.Final (broken starting with 3.1.0, fine with 3.0.4)

Quarkus 3.1.0 upgraded the driver to com.oracle.database.jdbc:ojdbc11:23.2.0.0 from com.oracle.database.jdbc:ojdbc11:21.5.0.0 so that explains why it started to fail.

As a workaround, you could downgrade the oracle driver.

@Felk
Copy link
Contributor Author

Felk commented Jul 31, 2023

Thanks for narrowing the problem down further! Downgrading the driver back to 21 worked.

I couldn't find an official place to report oracle database or jdbc driver bugs to Oracle, so if it's okay with you I'll try posting on their forums with a link to this issue and your reproducer, and close this one as it's not Quarkus' fault. Does that sound good?

@yrodiere yrodiere added triage/upstream and removed area/hibernate-orm Hibernate ORM labels Jul 31, 2023
@yrodiere
Copy link
Member

Hey @Felk , LGTM, thanks!

Please remember to post a link to your post here, so that others facing the same problem can follow progress on the Oracle side of things :)

Closing as this is not strictly caused by Quarkus, and I expect a fix in the Oracle JDBC driver will take some time.

@yrodiere yrodiere closed this as not planned Won't fix, can't repro, duplicate, stale Jul 31, 2023
@Felk
Copy link
Contributor Author

Felk commented Jul 31, 2023

@Felk
Copy link
Contributor Author

Felk commented Jul 23, 2024

This is properly fixed now in Quarkus due to #41998 which updated the Oracle JDBC driver to 23.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants