Search code examples
javajpaintellij-ideajpa-buddy

@Lob annotation JPA Buddy creates a script with the attribute of type TEXT


I encountered a bug when creating an init script from the java classes for flyway with a postgresql database. If you have an attribute of type string with the @Lob annotation jpa buddy creates a script with the attribute of type TEXT. Hibernate expects this to be of type oid because postgresql stores large objects in a separated table.

IntelliJ IDEA 2022.2.1 (Ultimate Edition); JPA Buddy2022.5.2-222; Spring Boot 2.7.7; flyway 9.10.2; Postgresql 15.1

What should I do to make it generate OID?


Solution

    1. Open Type Mappings Settings (Tools -> JPA Buddy -> Database Versionong -> Type Mappings) 
    2. Select postgresql type 
    3. Add custom Mapping Type for the jakarta.persistence.Lob or javax.persistence.Lob or java.lang.LobString and mapping to oid SQL type

    See the picture below: enter image description here