New versions: Dev (3.15) | Latest (3.14) | 3.13 | 3.12 | 3.11 | 3.10 | 3.9 | 3.8 | Old versions: 3.7 | 3.6 | 3.5 | 3.4 | 3.3 | 2.6

Generated records

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

Every table in your database will generate an org.jooq.Record implementation that looks like this:

// JPA annotations can be generated, optionally
@Entity
@Table(name = "BOOK", schema = "TEST")
public class BookRecord extends UpdatableRecordImpl<BookRecord>

// An interface common to records and pojos can be generated, optionally
implements IBook {

    // Every column generates a setter and a getter
    @Override
    public void setId(Integer value) {
        setValue(BOOK.ID, value);
    }
    
    @Id
    @Column(name = "ID", unique = true, nullable = false, precision = 7)
    @Override
    public Integer getId() {
        return getValue(BOOK.ID);
    }
    
    // More setters and getters
    public void setAuthorId(Integer value) {...}
    public Integer getAuthorId() {...}
    
    // Convenience methods for foreign key methods
    public void setAuthorId(AuthorRecord value) {
        if (value == null) {
            setValue(BOOK.AUTHOR_ID, null);
        }
        else {
            setValue(BOOK.AUTHOR_ID, value.getValue(AUTHOR.ID));
        }
    }
    
    // Navigation methods
    public AuthorRecord fetchAuthor() {
        return create.selectFrom(AUTHOR).where(AUTHOR.ID.eq(getValue(BOOK.AUTHOR_ID))).fetchOne();
    }
    
    // [...]
}

Flags influencing generated records

These flags from the code generation configuration influence generated records:

  • dateAsTimestamp: This influences all relevant getters and setters
  • unsignedTypes: This influences all relevant getters and setters
  • relations: This is needed as a prerequisite for navigation methods
  • navigationMethods: This controls whether navigation methods will be generated or not
  • daos: Records are a pre-requisite for DAOs. If DAOs are generated, records are generated as well
  • interfaces: If interfaces are generated, records will implement them
  • jpaAnnotations: JPA annotations are used on generated records

Flags controlling record generation

Record generation can be deactivated using the records flag

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo