2

I have some Oracle-tables where some of the PK-fields are defined as CHAR(9), and all values are stored with padding.

Thus, I have to retrieve all objects with space-padding in the key-fields. However, when EclipseLink reads the data into the object, the spaces are trimmed away. Since this occurs on the ID-values, there is no way for me to use @PostLoad in order to 'fix' the key so it will contain the spaces.

I have no way of deleting/updating the object since the key-value is changed to a trimmed value, and any update/delete misses on the key-value.

How can I configure my persistence-unit so it doesn't trim values for CHAR-columns ?

Joseph Quinsey
  • 9,553
  • 10
  • 54
  • 77

1 Answers1

3

You can use a SessionCustomizer to configure this,

public MyCustomizer implements SessionCustomizer {
  public customize(Session session) {
    session.getLogin().setShouldTrimStrings(false);
  }
}

But in general using CHAR instead of VARCHAR is normally a very bad idea.

James
  • 17,965
  • 11
  • 91
  • 146