Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2558

Implement a way to select the db representation of Boolean values

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.0, 2.4.0
    • 2.2.3, 2.4.0
    • jdbc
    • None

    Description

      Many Databases do not natively support the SQL-99 BOOLEAN datatype. Boolean and boolean fields in JPA entities will thus get represented as another type in the database. OpenJPA currently has a hardcoded mapping to int 1/0 in the base DBDictionary.

      But many existing databases don't use NUMBER(1) as column type but e.g. CHAR(1) (because it uses less space in the index).
      There are also all sorts of possible representations where one of those is usually consistently used throughout a customer application:

      • Native Boolean -> PreparedStatement#setBoolean
      • Int 0/1 -> PreparedStatement#setInt
      • String "Y"/"N" -> PreparedStatement#setString
      • String "T"/"F" -> PreparedStatement#setString
      • String "y"/"n" -> PreparedStatement#setString
      • String "t"/"f" -> PreparedStatement#setString

      And I've also seen translated ones: "J"/"N" in german apps for "Ja"/ "Nein" (yes/no).

      So it should be possible to even add your own custom BooleanRepresentation.

      Attachments

        1. OJ2558-2.2.x.patch
          31 kB
          Jody Grassel
        2. OPENJPA-2558.patch
          16 kB
          Mark Struberg

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            struberg Mark Struberg
            struberg Mark Struberg
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment