-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Hibernate support --------- Signed-off-by: Avgustin Marinov <[email protected]>
- Loading branch information
1 parent
af50e8c
commit db3ac7f
Showing
51 changed files
with
1,397 additions
and
704 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Verify (Hibernate) | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths-ignore: | ||
- '.3rd-party/**' | ||
- 'site/**' | ||
- '**.md' | ||
pull_request: | ||
paths-ignore: | ||
- '.3rd-party/**' | ||
- 'site/**' | ||
- '**.md' | ||
|
||
jobs: | ||
verify-hibernate: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
rabbitmq: | ||
image: rabbitmq:3-management-alpine | ||
env: | ||
RABBITMQ_DEFAULT_VHOST: / | ||
RABBITMQ_DEFAULT_USER: guest | ||
RABBITMQ_DEFAULT_PASS: guest | ||
ports: | ||
- 15672:15672 | ||
- 5672:5672 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: 17 | ||
cache: 'maven' | ||
|
||
- name: Check file license headers | ||
run: mvn license:check --batch-mode | ||
|
||
- name: Run tests & javadoc | ||
run: mvn verify javadoc:javadoc --batch-mode -Djpa.vendor=hibernate -Dlogging.level.org.hibernate.collection.spi.AbstractPersistentCollection=ERROR |
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
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,3 @@ | ||
# hawkBit JPA EclipseLink Vendor integration | ||
|
||
Implementation of [EclipseLink](http://www.eclipse.org/eclipselink/) JPA vendor. |
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,54 @@ | ||
<!-- | ||
Copyright (c) 2015 Bosch Software Innovations GmbH and others | ||
This program and the accompanying materials are made | ||
available under the terms of the Eclipse Public License 2.0 | ||
which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
SPDX-License-Identifier: EPL-2.0 | ||
--> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.eclipse.hawkbit</groupId> | ||
<version>${revision}</version> | ||
<artifactId>hawkbit-repository</artifactId> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>hawkbit-repository-jpa-api</artifactId> | ||
<name>hawkBit :: Repository :: JPA API</name> | ||
|
||
<properties> | ||
<apt.source.dir>${project.build.directory}/generated-sources/apt/</apt.source.dir> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.eclipse.hawkbit</groupId> | ||
<artifactId>hawkbit-repository-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.hibernate.orm</groupId> | ||
<artifactId>hibernate-core</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
<!-- Static class generation --> | ||
<dependency> | ||
<groupId>org.hibernate.orm</groupId> | ||
<artifactId>hibernate-jpamodelgen</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
</dependencies> | ||
</project> |
File renamed without changes.
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
File renamed without changes.
114 changes: 114 additions & 0 deletions
114
...ry-jpa-api/src/main/java/org/eclipse/hawkbit/repository/jpa/model/AbstractBaseEntity.java
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,114 @@ | ||
/** | ||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.hawkbit.repository.jpa.model; | ||
|
||
import java.io.Serializable; | ||
|
||
import jakarta.persistence.EntityListeners; | ||
import jakarta.persistence.MappedSuperclass; | ||
import jakarta.persistence.PostPersist; | ||
import jakarta.persistence.PostRemove; | ||
import jakarta.persistence.PostUpdate; | ||
|
||
import org.eclipse.hawkbit.repository.jpa.model.helper.AfterTransactionCommitExecutorHolder; | ||
import org.eclipse.hawkbit.repository.model.BaseEntity; | ||
import org.eclipse.hawkbit.tenancy.TenantAwareAuthenticationDetails; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
|
||
/** | ||
* Core information of all entities. | ||
*/ | ||
@MappedSuperclass | ||
@EntityListeners({ AuditingEntityListener.class, EntityInterceptorListener.class }) | ||
public abstract class AbstractBaseEntity implements BaseEntity, Serializable { | ||
|
||
/** | ||
* Defined equals/hashcode strategy for the repository in general is that an entity is equal if it has the same {@link #getId()} and | ||
* {@link #getOptLockRevision()} and class. | ||
*/ | ||
@Override | ||
// Exception squid:S864 - generated code | ||
@SuppressWarnings({ "squid:S864" }) | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + (getId() == null ? 0 : getId().hashCode()); | ||
result = prime * result + getOptLockRevision(); | ||
result = prime * result + getClass().getName().hashCode(); | ||
return result; | ||
} | ||
|
||
/** | ||
* Defined equals/hashcode strategy for the repository in general is that an entity is equal if it has the same {@link #getId()} and | ||
* {@link #getOptLockRevision()} and class. | ||
*/ | ||
@Override | ||
public boolean equals(final Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (!getClass().isInstance(obj)) { | ||
return false; | ||
} | ||
final BaseEntity other = (BaseEntity) obj; | ||
final Long id = getId(); | ||
final Long otherId = other.getId(); | ||
if (id == null) { | ||
if (otherId != null) { | ||
return false; | ||
} | ||
} else if (!id.equals(otherId)) { | ||
return false; | ||
} | ||
return getOptLockRevision() == other.getOptLockRevision(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getClass().getSimpleName() + " [id=" + getId() + "]"; | ||
} | ||
|
||
@PostPersist | ||
public void postInsert() { | ||
if (this instanceof EventAwareEntity eventAwareEntity) { | ||
doNotify(eventAwareEntity::fireCreateEvent); | ||
} | ||
} | ||
|
||
@PostUpdate | ||
public void postUpdate() { | ||
if (this instanceof EventAwareEntity eventAwareEntity) { | ||
doNotify(eventAwareEntity::fireUpdateEvent); | ||
} | ||
} | ||
|
||
@PostRemove | ||
public void postDelete() { | ||
if (this instanceof EventAwareEntity eventAwareEntity) { | ||
doNotify(eventAwareEntity::fireDeleteEvent); | ||
} | ||
} | ||
|
||
protected static void doNotify(final Runnable runnable) { | ||
// fire events onl AFTER transaction commit | ||
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit().afterCommit(runnable); | ||
} | ||
|
||
protected boolean isController() { | ||
return SecurityContextHolder.getContext().getAuthentication() != null | ||
&& SecurityContextHolder.getContext().getAuthentication() | ||
.getDetails() instanceof TenantAwareAuthenticationDetails tenantAwareDetails | ||
&& tenantAwareDetails.isController(); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
hawkbit-repository/hawkbit-repository-jpa-eclipselink/README.md
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,3 @@ | ||
# hawkBit JPA EclipseLink Vendor integration | ||
|
||
Implementation of [EclipseLink](http://www.eclipse.org/eclipselink/) JPA vendor. |
49 changes: 49 additions & 0 deletions
49
hawkbit-repository/hawkbit-repository-jpa-eclipselink/pom.xml
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,49 @@ | ||
<!-- | ||
Copyright (c) 2015 Bosch Software Innovations GmbH and others | ||
This program and the accompanying materials are made | ||
available under the terms of the Eclipse Public License 2.0 | ||
which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
SPDX-License-Identifier: EPL-2.0 | ||
--> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.eclipse.hawkbit</groupId> | ||
<version>${revision}</version> | ||
<artifactId>hawkbit-repository</artifactId> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>hawkbit-repository-jpa-eclipselink</artifactId> | ||
<name>hawkBit :: Repository :: JPA EclipseLink Vendor</name> | ||
|
||
<properties> | ||
<apt.source.dir>${project.build.directory}/generated-sources/apt/</apt.source.dir> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.eclipse.hawkbit</groupId> | ||
<artifactId>hawkbit-repository-jpa-api</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<!-- Static class generation --> | ||
<dependency> | ||
<groupId>org.hibernate.orm</groupId> | ||
<artifactId>hibernate-jpamodelgen</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.eclipse.persistence</groupId> | ||
<artifactId>org.eclipse.persistence.jpa</artifactId> | ||
<version>${eclipselink.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
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
Oops, something went wrong.