Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target/
/.idea/
.env
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM eclipse-temurin:21-jdk

COPY src/main/java/org/example/App.java /App.java

ENTRYPOINT ["java", "/App.java"]

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
42 changes: 42 additions & 0 deletions dfg
Original file line number Diff line number Diff line change
@@ -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 <martin.blomberg@outlook.com>
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] <support@github.com>
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
16 changes: 16 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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:
46 changes: 46 additions & 0 deletions src/main/java/org/example/entities/Booking.java
Original file line number Diff line number Diff line change
@@ -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; }
}
26 changes: 26 additions & 0 deletions src/main/resources/META-INF/persistence.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence version="3.2"
xmlns="https://jakarta.ee/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_2.xsd">

<persistence-unit name="jpa-hibernate-mysql">

<!-- Entities -->
<class>org.example.entities.Booking</class>

<properties>
<!-- JDBC -->
<property name="jakarta.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="jakarta.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/app_db"/>
<property name="jakarta.persistence.jdbc.user" value="root"/>
<property name="jakarta.persistence.jdbc.password" value="rootpassword"/>

<!-- Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
</properties>

</persistence-unit>
</persistence>