Skip to content

Model command

José Vieira Neto edited this page Aug 4, 2019 · 2 revisions

This command have the goal generate models with jpa orm

How to use

$ spring model -n "User" -p "name:String email:String"
[INFO] org.projectlombok already added.
CREATED src/main/java/com/example/cloudawsmessaging/models/User.java

content

import lombok.Data;
import java.util.List;

@Entity
@Data
public class User {

        @Id @GeneratedValue(strategy = GenerationType.AUTO)
        private Integer id;
        private String name;
        private String email;
}

With relationships

$ spring model -n "Pet" -p "name:String Owner:references(relation:belongsTo, name:String)"
[INFO] org.projectlombok already added.
CREATED src/main/java/com/example/cloudawsmessaging/models/Owner.java
CREATED src/main/java/com/example/cloudawsmessaging/models/Pet.java

content

import lombok.Data;
import java.util.List;

@Entity
@Data
public class Pet {

        @Id @GeneratedValue(strategy = GenerationType.AUTO)
        private Integer id;
        private String name;

        @OneToOne
        private Owner owner;
}
import lombok.Data;
import java.util.List;

@Entity
@Data
public class Owner {
        private String name;
}

Types supported

  • String
  • Int
  • Date

Relationships supported

  • belongsTo
  • hasMany

(help us, contributing to support more types and relationships)

Clone this wiki locally