diff --git a/.gitignore b/.gitignore index 6ac465db..244268f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ target/ /.idea/ +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..2213772e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM eclipse-temurin:21-jdk + +COPY src/main/java/org/example/App.java /App.java + +ENTRYPOINT ["java", "/App.java"] + diff --git a/README.md b/README.md index 5150e50f..05def9a9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/_uV8Mn8f) # 📘 Projektarbete: JPA + Hibernate med GitHub-flöde Projektet genomförs som antingen en Java CLI-applikation eller med hjälp av JavaFX om ni vill ha ett grafiskt gränssnitt. diff --git a/dfg b/dfg new file mode 100644 index 00000000..6dac856d --- /dev/null +++ b/dfg @@ -0,0 +1,42 @@ +commit 149e0caf9a2d36b0dfd9254b37c62c2bb73d2f0c (HEAD -> main, origin/main, origin/HEAD) +Author: github-classroom[bot] <66690702+github-classroom[bot]@users.noreply.github.com> +Date: Mon Dec 15 09:40:48 2025 +0000 + + add deadline + +commit 879440803daa45b536e2ea5f3ec269d1be62bf04 (upstream/main, upstream/HEAD) +Author: Martin Blomberg +Date: Sun Dec 14 16:07:37 2025 +0100 + + Setup for JPA application + +commit 539e1a559ab7607b40651315e45ef50074c51b8c +Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> +Date: Sun Dec 14 12:52:36 2025 +0000 + + Bump org.mockito:mockito-junit-jupiter in the maven-deps group (#1) + + Bumps the maven-deps group with 1 update: [org.mockito:mockito-junit-jupiter](https://github.com/mockito/mockito). + + + Updates `org.mockito:mockito-junit-jupiter` from 5.20.0 to 5.21.0 + - [Release notes](https://github.com/mockito/mockito/releases) + - [Commits](https://github.com/mockito/mockito/compare/v5.20.0...v5.21.0) + + --- + updated-dependencies: + - dependency-name: org.mockito:mockito-junit-jupiter + dependency-version: 5.21.0 + dependency-type: direct:development + update-type: version-update:semver-minor + dependency-group: maven-deps + ... + + Signed-off-by: dependabot[bot] + Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> + +commit c9a2be0c3d4286e6322bb017f66aa77bbaaa5a00 +Author: github-classroom[bot] <66690702+github-classroom[bot]@users.noreply.github.com> +Date: Sun Dec 14 12:51:33 2025 +0000 + + Initial commit diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000..282619f1 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,16 @@ +services: + mysql: + image: mysql:9.5.0 + container_name: mysql + restart: always + environment: + MYSQL_ROOT_PASSWORD: rootpassword + MYSQL_DATABASE: app_db + MYSQL_USER: + MYSQL_PASSWORD: PASSWORD + ports: + - "3306:3306" + volumes: + - mysql_data:/var/lib/mysql +volumes: + mysql_data: diff --git a/src/main/java/org/example/entities/Booking.java b/src/main/java/org/example/entities/Booking.java new file mode 100644 index 00000000..4832a48b --- /dev/null +++ b/src/main/java/org/example/entities/Booking.java @@ -0,0 +1,46 @@ +package org.example.entities; + +import jakarta.persistence.*; +import java.time.LocalDateTime; + +@Entity +@Table(name = "booking") +public class Booking { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "restaurant_id", nullable = false) + private Long restaurantId; + + @Column(name = "customer_id", nullable = false) + private Long customerId; + + @Column(name = "table_id", nullable = false) + private Long tableId; + + @Column(name = "booking_start", nullable = false) + private LocalDateTime bookingStart; + + @Column(name = "booking_end", nullable = false) + private LocalDateTime bookingEnd; + + protected Booking() { } + + public Booking(Long restaurantId, Long customerId, Long tableId, + LocalDateTime bookingStart, LocalDateTime bookingEnd) { + this.restaurantId = restaurantId; + this.customerId = customerId; + this.tableId = tableId; + this.bookingStart = bookingStart; + this.bookingEnd = bookingEnd; + } + + public Long getId() { return id; } + public Long getRestaurantId() { return restaurantId; } + public Long getCustomerId() { return customerId; } + public Long getTableId() { return tableId; } + public LocalDateTime getBookingStart() { return bookingStart; } + public LocalDateTime getBookingEnd() { return bookingEnd; } +} diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml new file mode 100644 index 00000000..c2506b42 --- /dev/null +++ b/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,26 @@ + + + + + + + org.example.entities.Booking + + + + + + + + + + + + + + + +