UML

Unidirectional OneToOne UML relationshipUnidirectional OneToOne UML relationship

Kukulkan Grammar

    entity Left {
        OneToOne attRight: Right
    }
    entity Right {}

Data Model

Unidirectional OneToOne Data ModelUnidirectional OneToOne Data Model

Foreign Keys:

Java (POJO)

    @Entity
    @Table(name = "lefts")
    public class Left implements Serializable {
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", unique = true, nullable = false)
        private Long id;

        @OneToOne
        @JoinColumn(name = "att_right_id", unique = true)
        private Right attRight;

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
        this.id = id;
        }

        public Right getAttRight() {
            return attRight;
        }

        public void setAttRight(Right attRight) {
            this.attRight = attRight;
        }

    }

    @Entity
    @Table(name = "rights")
    public class Right implements Serializable {
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", unique = true, nullable = false)
        private Long id;

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
        this.id = id;
        }

    }

UML

Unidirectional OneToMany UML relationshipUnidirectional OneToMany UML relationship

Unsupported!

The Left entity must always be navigable from Right entity.

This case will be the same as Bidirectional OneToMany

UML

Unidirectional ManyToOne UML relationshipUnidirectional ManyToOne UML relationship

Kukulkan Grammar

    entity Left {
        ManyToOne attRight: Right
    }
    entity Right {}

Data Model

Unidirectional ManyToOne Data ModelUnidirectional ManyToOne Data Model

Foreign Keys:

Java (POJO)

    @Entity
    @Table(name = "lefts")
    public class Left implements Serializable {
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", unique = true, nullable = false)
        private Long id;

        @ManyToOne
        @JoinColumn(name = "att_right_id")
        private Right attRight;

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
        this.id = id;
        }

        public Right getAttRight() {
            return attRight;
        }

        public void setAttRight(Right attRight) {
            this.attRight = attRight;
        }

    }

    @Entity
    @Table(name = "rights")
    public class Right implements Serializable {
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", unique = true, nullable = false)
        private Long id;

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
        this.id = id;
        }

    }

UML

Unidirectional ManyToMany UML relationshipUnidirectional ManyToMany UML relationship

Kukulkan Grammar

    entity Left {
        ManyToMany attsRight: Right
    }
    entity Right {}

Data Model

Unidirectional ManyToMany Data ModelUnidirectional ManyToMany Data Model

Foreign Keys:

Java (POJO)

    @Entity
    @Table(name = "lefts")
    public class Left implements Serializable {
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", unique = true, nullable = false)
        private Long id;

        @ManyToMany
        @JoinTable(name = "lefts_atts_right", 
        joinColumns = JoinColumn(name="left_id", referencedColumnName="id"),
        inverseJoinColumns = 
        @JoinColumn(name="att_right_id", referencedColumnName="id"))
        private Set<Right> attsRight = new HashSet<>();

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
        this.id = id;
        }

        public Set<Right> getAttsRight() {
            return attsRight;
        }

        public void setAttsRight(Set<Right> attsRight) {
            this.attsRight = attsRight;
        }

        public Left addAttRight (Right attsRight) {
            this.attsRight.add(attsRight);
            attsRight.getLeft().add(this);
            return this;
        }

        public Left removeAttRight(Right attsRight) {
            this.attsRight.remove(attsRight);
            attsRight.getLeft().remove(this);
            return this;
        } 

    }

    @Entity
    @Table(name = "rights")
    public class Right implements Serializable {
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", unique = true, nullable = false)
        private Long id;

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
            this.id = id;
        } 

    }

UML

Bidirectional OneToOne UML relationshipBidirectional OneToOne UML relationship

Kukulkan Grammar

    entity Left {
        OneToOne (attLeft) attRight: Right
    }
    entity Right {}

Data Model

Bidirectional OneToOne Data ModelBidirectional OneToOne Data Model

Foreign Keys:

Java (POJO)

    @Entity
    @Table(name = "lefts")
    public class Left implements Serializable {
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", unique = true, nullable = false)
        private Long id;

        @OneToOne
        @JoinColumn(name = "att_right_id", unique = true)
        private Right attRight;

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
        this.id = id;
        }

        public Right getAttRight() {
            return attRight;
        }

        public void setAttRight(Right attRight) {
            this.attRight = attRight;
        }

    }

    @Entity
    @Table(name = "rights")
    public class Right implements Serializable {
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", unique = true, nullable = false)
        private Long id;

        @OneToOne(mappedBy = "attRight")
        private Left attLeft;

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
        this.id = id;
        }    
        
        public Left getAttLeft() {
            return attLeft;
        }

        public void setAttLeft(Left attLeft) {
            this.attLeft = attLeft;
        }

    }

UML

Bidirectional OneToMany UML relationshipBidirectional OneToMany UML relationship

Kukulkan Grammar

    entity Left {
        OneToMany (attLeft) attsRight: Right
    }
    entity Right {}

Data Model

Bidirectional OneToMany Data ModelBidirectional OneToMany Data Model

Foreign Keys:

Java (POJO)

    @Entity
    @Table(name = "lefts")
    public class Left implements Serializable {
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", unique = true, nullable = false)
        private Long id;

        @OneToMany(mappedBy = "attLeft")
        @JsonIgnore
        private Set<Right> attsRight = new HashSet<>();

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
        this.id = id;
        }

        public Set<Right> getAttsRight() {
            return attsRight;
        }

        public void setAttsRight(Set<Right> attsRight) {
            this.attsRight = attsRight;
        }

        public Left addAttRight (Right attRight) {
            this.attsRight.add(attRight);
            attRight.getLeft().add(this);
            return this;
        }

        public Left removeAttRight(Right attRight) {
            this.attsRight.remove(attRight);
            attRight.getLeft().remove(this);
            return this;
        } 

    }

    @Entity
    @Table(name = "rights")
    public class Right implements Serializable {
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", unique = true, nullable = false)
        private Long id;

        @ManyToOne
        @JoinColumn(name = "att_left_id")
        private Left attLeft;

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
        this.id = id;
        }    
        
        public Left getAttLeft() {
            return attLeft;
        }

        public void setAttLeft(Left attLeft) {
            this.attLeft = attLeft;
        }

    }

UML

Bidirectional ManyToOne UML relationshipBidirectional ManyToOne UML relationship

Kukulkan Grammar

    entity Left {
        ManyToOne (attsLeft) attRight: Right
    }
    entity Right {}

Data Model

Bidirectional ManyToOne Data ModelBidirectional ManyToOne Data Model

Foreign Keys:

Java (POJO)

    @Entity
    @Table(name = "lefts")
    public class Left implements Serializable {
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", unique = true, nullable = false)
        private Long id;

        @ManyToOne
        @JoinColumn(name = "att_right_id")
        private Right attRight;

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
        this.id = id;
        }

        public Right getAttRight() {
            return attRight;
        }

        public void setAttRight(Right attRight) {
            this.attRight = attRight;
        }

    }

    @Entity
    @Table(name = "rights")
    public class Right implements Serializable {
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", unique = true, nullable = false)
        private Long id;

        @OneToMany(mappedBy = "attRight")
        private Set<Left> attsLeft = new HashSet<>();

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
        this.id = id;
        }	    
        
        public Set<Left> getAttsLeft() {
            return attsLeft;
        }

        public void setAttsLeft(Set<Left> attsLeft) {
            this.attsLeft = attsLeft;
        }

    }

UML

Bidirectional ManyToMany UML relationshipBidirectional ManyToMany UML relationship

Kukulkan Grammar

    entity Left {
        ManyToMany (attsLeft) attsRight: Right
    }
    entity Right {}

Data Model

Bidirectional ManyToMany Data ModelBidirectional ManyToMany Data Model

Foreign Keys:

Java (POJO)

    @Entity
    @Table(name = "lefts")
    public class Left implements Serializable {
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", unique = true, nullable = false)
        private Long id;

        @ManyToMany
        @JoinTable(name = "atts_left_atts_right", 
        joinColumns = JoinColumn(name="att_left_id", referencedColumnName="id"),
        inverseJoinColumns = 
        @JoinColumn(name="att_right_id", referencedColumnName="id"))
        private Set<Right> attsRight = new HashSet<>();

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
        this.id = id;
        }

        public Set<Right> getAttsRight() {
            return attsRight;
        }

        public void setAttsRight(Set<Right> attsRight) {
            this.attsRight = attsRight;
        }

        public Left addAttRight (Right attsRight) {
            this.attsRight.add(attsRight);
            attsRight.getLeft().add(this);
            return this;
        }

        public Left removeAttRight(Right attsRight) {
            this.attsRight.remove(attsRight);
            attsRight.getLeft().remove(this);
            return this;
        } 

    }

    @Entity
    @Table(name = "rights")
    public class Right implements Serializable {
        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", unique = true, nullable = false)
        private Long id;

        @ManyToMany(mappedBy = "attsRight")
        @JsonIgnore
        private Set<Left> attsLeft = new HashSet<>();

        public Long getId() {
            return id;
        }

        public void setId(Long id) {
        this.id = id;
        }

        public Set<Left> getLefts() {
            return attsLeft;
        }

        public void setLefts(Set<Left> attsLeft) {
            this.attsLeft = attsLeft;
        }

        public Right addLeft(Left left) {
            this.attsLeft.add(left);
            left.getAttsRight().add(this);
            return this;
        }

        public Right removeLeft(Lefts left) {
            this.lefts.remove(left);
            lefts.getAttsRight().remove(this);
            return this;
        }  

    }