-
Notifications
You must be signed in to change notification settings - Fork 49
Model command
José Vieira Neto edited this page Aug 4, 2019
·
2 revisions
This command have the goal generate models with jpa orm
$ 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;
}
$ 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;
}
- String
- Int
- Date
- belongsTo
- hasMany
(help us, contributing to support more types and relationships)