Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BIGTOP-4192: Switch ORM framework from JPA to MyBatis #54

Merged
merged 17 commits into from
Aug 29, 2024
36 changes: 15 additions & 21 deletions bigtop-manager-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
<commons-compress.version>1.26.2</commons-compress.version>
<jwt.version>4.4.0</jwt.version>
<janino.version>3.0.16</janino.version>
<eclipse-link.version>4.0.2</eclipse-link.version>
<jaxb-runtime.version>4.0.4</jaxb-runtime.version>
<hibernate-core.version>6.2.5.Final</hibernate-core.version>
<commons-text.version>1.11.0</commons-text.version>
<prometheus-java-client.version>1.0.0</prometheus-java-client.version>
<oshi-core.version>6.4.11</oshi-core.version>
<micrometer.version>1.12.4</micrometer.version>
<jdbc.dm.version>8.1.2.192</jdbc.dm.version>
<langchain4j.version>0.33.0</langchain4j.version>
<mybatis-spring-boot-starter.version>3.0.3</mybatis-spring-boot-starter.version>
<pagehelper-spring-boot-starter.version>2.1.0</pagehelper-spring-boot-starter.version>
</properties>

<dependencyManagement>
Expand All @@ -69,18 +69,6 @@
<version>${springdoc.version}</version>
</dependency>

<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>${eclipse-link.version}</version>
</dependency>

<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.extension</artifactId>
<version>${eclipse-link.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
Expand Down Expand Up @@ -159,13 +147,6 @@
<version>${jaxb-runtime.version}</version>
</dependency>

<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate-core.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
Expand Down Expand Up @@ -203,6 +184,19 @@
<version>${oshi-core.version}</version>
</dependency>

<!-- mybatis -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-spring-boot-starter.version}</version>
</dependency>

<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper-spring-boot-starter.version}</version>
</dependency>

<!-- dameng -->
<dependency>
<groupId>com.dameng</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,37 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum Command {
CREATE,
CREATE("create", "Create"),

INSTALL,
INSTALL("install", "Install"),

UNINSTALL,
UNINSTALL("uninstall", "Uninstall"),

START,
START("start", "Start"),

STOP,
STOP("stop", "Stop"),

STATUS,
STATUS("status", "Status"),

RESTART,
RESTART("restart", "Restart"),

CONFIGURE,
CONFIGURE("configure", "Configure"),

CHECK,
CHECK("check", "Check"),

CUSTOM,
CUSTOM("custom", "Custom"),
;

private final String code;

private final String name;

@JsonCreator
public static Command fromString(String value) {
return Command.valueOf(value.toUpperCase());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,27 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum JobState {
PENDING,
PENDING("pending", "Pending"),

PROCESSING,
PROCESSING("processing", "Processing"),

SUCCESSFUL,
SUCCESSFUL("successful", "Successful"),

FAILED,
FAILED("failed", "Failed"),

CANCELED,
CANCELED("canceled", "Canceled"),
;

private final String code;

private final String name;

@JsonCreator
public static JobState fromString(String value) {
return JobState.valueOf(value.toUpperCase());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,25 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum MaintainState {
UNINSTALLED,
UNINSTALLED("uninstalled", "Uninstalled"),

INSTALLED,
INSTALLED("installed", "Installed"),

MAINTAINED,
MAINTAINED("maintained", "Maintained"),

STARTED,
STARTED("started", "Started"),

STOPPED,
;
STOPPED("stopped", "Stopped");

private final String code;

private final String name;

@JsonCreator
public static MaintainState fromString(String value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.bigtop.manager.common.utils;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ClassUtils {

/**
* Get all Fields
*/
public static List<Field> getFields(Class<?> loadClass) {
List<Field> fieldList = new ArrayList<>();

while (loadClass != null) {
fieldList.addAll(Arrays.asList(loadClass.getDeclaredFields()));
loadClass = loadClass.getSuperclass();
}
return fieldList;
}
}
5 changes: 3 additions & 2 deletions bigtop-manager-dao/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@
</dependency>

<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,24 @@
import lombok.Data;
import lombok.EqualsAndHashCode;

import jakarta.persistence.Basic;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import jakarta.persistence.TableGenerator;
import java.io.Serializable;

@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "audit_log")
@TableGenerator(
name = "audit_log_generator",
table = "sequence",
pkColumnName = "seq_name",
valueColumnName = "seq_count")
public class AuditLogPO extends BasePO {
public class AuditLogPO extends BasePO implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "audit_log_generator")
@Column(name = "id")
private Long id;

@Column(name = "uri")
private String uri;

@Lob
@Basic(fetch = FetchType.LAZY)
@Column(name = "args", length = 16777216)
@Column(name = "args")
private String args;

@Column(name = "tag_name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,23 @@
*/
package org.apache.bigtop.manager.dao.po;

import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import lombok.Data;

import jakarta.persistence.Column;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import java.sql.Timestamp;

@Data
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class BasePO {

@CreatedDate
@Column(name = "create_time", updatable = false)
@Column(name = "create_time")
private Timestamp createTime;

@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;

@CreatedBy
@Column(name = "create_by", updatable = false)
@Column(name = "create_by")
private Long createBy;

@LastModifiedBy
@Column(name = "update_by")
private Long updateBy;
}
Loading
Loading