I do not like the order of the columns in the database h2. I use Auditing to create tables.
Example code
package ru.omega.vaccination.model.dto.audit;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
import java.time.Instant;
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
@JsonIgnoreProperties(
value = {"createdAt", "updatedAt"},
allowGetters = true
)
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public abstract class DateAudit implements Serializable {
@CreatedDate
@Column(nullable = true, updatable = false)
private Instant createdAt;
@LastModifiedDate
@Column(nullable = true)
private Instant updatedAt;
}
And
@Entity(name = "people")
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class People extends DateAudit {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", updatable = false, nullable = false)
private Long id;
@Column
private String lastname;
@Column
private String firstname;
@Column
private String patronymic;
...
}
I would like to move the "CREATED_AT" "UPDATED_AT" columns to the end of the table. I can't find a way to implement this. I would be glad to see code examples to solve such a problem.