Spring JPA file added

This commit is contained in:
YuCheng Hu 2020-04-04 23:17:09 -04:00
parent 6d8013ed9f
commit eaeac79efd
3 changed files with 62 additions and 1 deletions

View File

@ -9,7 +9,7 @@ import org.springframework.context.annotation.Bean;
import java.util.Arrays;
/**
*
* MAIN APPLICATION
*/
@SpringBootApplication
public class SpringBootH2ConsoleApplication {

View File

@ -0,0 +1,7 @@
package com.ossez.h2db.springboot.daos;
import com.ossez.h2db.springboot.models.User;
import org.springframework.data.repository.CrudRepository;
public interface UserRepository extends CrudRepository<User, Integer> {
}

View File

@ -0,0 +1,54 @@
package com.ossez.h2db.springboot.models;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@Table(name = "user")
@Entity
public class User {
@Id
@GeneratedValue
private int id;
private String firstName;
private String lastName;
public User() { }
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public String toString() {
return "User{" +
"id=" + id +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
'}';
}
}