mirror of
https://gitlab.com/etc404/software-engineering-project.git
synced 2026-05-10 20:52:58 +00:00
this thing has the database
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package com.example.database;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.persistence.UniqueConstraint;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Column;
|
||||
|
||||
@Entity
|
||||
@Table(name = "ingredients", uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = "name")
|
||||
})
|
||||
public class Ingredient {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column(nullable = false, unique = true)
|
||||
private String name;
|
||||
|
||||
// Default constructor required by JPA
|
||||
public Ingredient() {}
|
||||
|
||||
// Convenience constructor
|
||||
public Ingredient(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
// Getters and setters
|
||||
public Integer getId() { return id; }
|
||||
public void setId(Integer id) { this.id = id; }
|
||||
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
}
|
||||
Reference in New Issue
Block a user