Skip to content

@OneToOne: fill optional attribute #29

@upachler

Description

@upachler

Currently, gentity ignores the distinction between 1:1 and 1:0..1 associations. The way @OneToOne is currently generated makes all @OneToOne associations optional=true by default (because true is the default value for the optional attribute if it is not specified, which is always the case right now).

For some background, consider the tables car and registration, where car has a foreign key column registration_id referring to registration's id column:

  • if registration_id is set as NOT NULL, then each car must have a registration. Therefore this is a 1:1 relation
  • if registration_id is set as NULL (nullable), then a car may have a registration (or it may not). This is a 1:0..1 relation.

Proposal:

  • For 1:0..1 relations, leave optional as the default (do not specify optional, as it is right now)
  • For 1:1 relations, specify optional=false in the @OneToOne annotation

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions