-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example model classes, update Gradle to v8.4
- Loading branch information
Showing
12 changed files
with
296 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright 2023 Thijs Koppen | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package ch.icken |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2023 Thijs Koppen | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package ch.icken.model | ||
|
||
import io.quarkus.hibernate.orm.panache.kotlin.PanacheCompanion | ||
import io.quarkus.hibernate.orm.panache.kotlin.PanacheEntity | ||
import jakarta.persistence.* | ||
|
||
@Entity | ||
@Table(name = "ASSIGNMENT") | ||
class Assignment( | ||
|
||
@OneToOne(optional = false) | ||
@JoinColumn(name = "EMPLOYEE_ID", unique = true, nullable = false) | ||
val employee: Employee, | ||
|
||
@ManyToOne(optional = false) | ||
@JoinColumn(name = "CLIENT_ID", nullable = false) | ||
val client: Client, | ||
|
||
@Column(name = "ROLE", nullable = false) | ||
var role: String | ||
|
||
) : PanacheEntity() { | ||
|
||
@Column(name = "DESCRIPTION") | ||
var description: String? = null | ||
|
||
companion object : PanacheCompanion<Assignment> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2023 Thijs Koppen | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package ch.icken.model | ||
|
||
import io.quarkus.hibernate.orm.panache.kotlin.PanacheCompanion | ||
import io.quarkus.hibernate.orm.panache.kotlin.PanacheEntity | ||
import jakarta.persistence.* | ||
|
||
@Entity | ||
@Table(name = "CLIENT") | ||
class Client( | ||
|
||
@Column(name = "NAME", unique = true, nullable = false) | ||
var name: String | ||
|
||
) : PanacheEntity() { | ||
|
||
@OneToMany(cascade = [CascadeType.ALL], mappedBy = "client", orphanRemoval = true) | ||
val assignments = HashSet<Assignment>() | ||
|
||
operator fun plusAssign(assignment: Assignment) { | ||
assignments.add(assignment) | ||
} | ||
operator fun minusAssign(assignment: Assignment) { | ||
assignments.remove(assignment) | ||
} | ||
|
||
companion object : PanacheCompanion<Client> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2023 Thijs Koppen | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package ch.icken.model | ||
|
||
import io.quarkus.hibernate.orm.panache.kotlin.PanacheCompanion | ||
import io.quarkus.hibernate.orm.panache.kotlin.PanacheEntity | ||
import jakarta.persistence.* | ||
|
||
@Entity | ||
@Table(name = "DEPARTMENT") | ||
class Department( | ||
|
||
@Column(name = "NAME", unique = true, nullable = false) | ||
var name: String | ||
|
||
) : PanacheEntity() { | ||
|
||
@OneToMany(cascade = [CascadeType.ALL], mappedBy = "department", orphanRemoval = true) | ||
val employees = HashSet<Employee>() | ||
|
||
operator fun plusAssign(employee: Employee) { | ||
employees.add(employee) | ||
} | ||
operator fun minusAssign(employee: Employee) { | ||
employees.remove(employee) | ||
} | ||
|
||
companion object : PanacheCompanion<Department> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2023 Thijs Koppen | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package ch.icken.model | ||
|
||
import io.quarkus.hibernate.orm.panache.kotlin.PanacheCompanion | ||
import io.quarkus.hibernate.orm.panache.kotlin.PanacheEntity | ||
import jakarta.persistence.* | ||
import java.time.LocalDateTime | ||
|
||
@Entity | ||
@Table(name = "EMPLOYEE") | ||
class Employee( | ||
|
||
@Column(name = "EMPLOYEE_NO", unique = true, nullable = false, updatable = false) | ||
val employeeNumber: Int, | ||
|
||
@Column(name = "FIRST_NAME", nullable = false) | ||
var firstName: String, | ||
|
||
@Column(name = "LAST_NAME", nullable = false) | ||
var lastName: String, | ||
|
||
@Column(name = "GENDER", nullable = false) | ||
@Enumerated(EnumType.STRING) | ||
var gender: Gender, | ||
|
||
@Column(name = "BIRTH_DATE", nullable = false, updatable = false) | ||
var birthDate: LocalDateTime, | ||
|
||
@ManyToOne(optional = false) | ||
@JoinColumn(name = "DEPARTMENT_ID", nullable = false) | ||
var department: Department, | ||
|
||
@Column(name = "SALARY", nullable = false) | ||
var salary: Double | ||
|
||
) : PanacheEntity() { | ||
|
||
@OneToOne(cascade = [CascadeType.ALL], mappedBy = "employee", orphanRemoval = true) | ||
var assignment: Assignment? = null | ||
|
||
companion object : PanacheCompanion<Employee> | ||
|
||
enum class Gender { | ||
M, F, X | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2023 Thijs Koppen | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package ch.icken.model | ||
|
||
import io.quarkus.test.junit.QuarkusTest | ||
import org.junit.jupiter.api.Test | ||
|
||
@QuarkusTest | ||
class EmployeeTest { | ||
|
||
@Test | ||
fun test() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# | ||
# Copyright 2023 Thijs Koppen | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
quarkus.datasource.db-kind=h2 | ||
quarkus.datasource.jdbc.url=jdbc:h2:mem:test | ||
|
||
quarkus.hibernate-orm.database.generation=drop-and-create | ||
quarkus.hibernate-orm.packages=ch.icken.model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
INSERT INTO DEPARTMENT (ID, NAME) VALUES | ||
(1, 'Sales'), | ||
(2, 'HR'); | ||
|
||
--INSERT INTO EMPLOYEE (ID, EMPLOYEE_NO, FIRST_NAME, LAST_NAME, GENDER, BIRTH_DATE, DEPARTMENT_ID, SALARY) VALUES | ||
--; | ||
|
||
--INSERT INTO CLIENT (ID, NAME) VALUES | ||
--; | ||
|
||
--INSERT INTO ASSIGNMENT (ID, EMPLOYEE_ID, CLIENT_ID, ROLE) VALUES | ||
--; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters