Why @JmixGeneratedValue is missing and id become String from UUID after re-import the Customer enity

package com.company.limsii.entity;

import io.jmix.core.metamodel.annotation.InstanceName;
import io.jmix.core.metamodel.annotation.JmixEntity;
import io.jmix.data.DdlGeneration;
import jakarta.persistence.*;

import java.util.Date;

@DdlGeneration(value = DdlGeneration.DbScriptGenerationMode.DISABLED)
@JmixEntity
@Table(name = “CUSTOMER”)
@Entity
public class Customer {
@Column(name = “ID”, nullable = false, length = 36)
@Id
private String id;

@Column(name = "ADDRESS", length = 500)
private String address;

@Column(name = "ATTENTION")
private String attention;

@Column(name = "CREATED_BY")
private String createdBy;

@Column(name = "CREATED_DATE")
@Temporal(TemporalType.TIMESTAMP)
private Date createdDate;

@Column(name = "DELETED_BY")
private String deletedBy;

@Column(name = "DELETED_DATE")
@Temporal(TemporalType.TIMESTAMP)
private Date deletedDate;

@Column(name = "FAX")
private String fax;

@Column(name = "LAST_MODIFIED_BY")
private String lastModifiedBy;

@Column(name = "LAST_MODIFIED_DATE")
@Temporal(TemporalType.TIMESTAMP)
private Date lastModifiedDate;

@Column(name = "LOCATION")
private String location;

@InstanceName
@Column(name = "NAME")
private String name;

@Column(name = "PHONE")
private String phone;

public String getPhone() {
    return phone;
}

public void setPhone(String phone) {
    this.phone = phone;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getLocation() {
    return location;
}

public void setLocation(String location) {
    this.location = location;
}

public Date getLastModifiedDate() {
    return lastModifiedDate;
}

public void setLastModifiedDate(Date lastModifiedDate) {
    this.lastModifiedDate = lastModifiedDate;
}

public String getLastModifiedBy() {
    return lastModifiedBy;
}

public void setLastModifiedBy(String lastModifiedBy) {
    this.lastModifiedBy = lastModifiedBy;
}

public String getFax() {
    return fax;
}

public void setFax(String fax) {
    this.fax = fax;
}

public Date getDeletedDate() {
    return deletedDate;
}

public void setDeletedDate(Date deletedDate) {
    this.deletedDate = deletedDate;
}

public String getDeletedBy() {
    return deletedBy;
}

public void setDeletedBy(String deletedBy) {
    this.deletedBy = deletedBy;
}

public Date getCreatedDate() {
    return createdDate;
}

public void setCreatedDate(Date createdDate) {
    this.createdDate = createdDate;
}

public String getCreatedBy() {
    return createdBy;
}

public void setCreatedBy(String createdBy) {
    this.createdBy = createdBy;
}

public String getAttention() {
    return attention;
}

public void setAttention(String attention) {
    this.attention = attention;
}

public String getAddress() {
    return address;
}

public void setAddress(String address) {
    this.address = address;
}

public String getId() {
    return id;
}

public void setId(String id) {
    this.id = id;
}

}

Why @JmixGeneratedValue is missing and id become String from UUID after re-import the Customer enity

Studio cannot be sure that a VARCHAR(36) column actually stores UUID. If you use a database that has a specific type for UUID, like PostgreSQL or Microsoft SQLServer, you it would map the column to Java UUID.

The same is for @JmixGeneratedValue - there is no any indication in the database that the column value must be generated automatically.

Of course we could add some heuristics to the reverse engineering and make assumptions for typical cases of tables generated by Jmix. But we need some motivation for making such changes. Could you explain your use case, why do you reverse-engineer these tables?

Regards,
Konstantin

Hello. Cause I create new column in a table in Database and have to import it to the Jmix entity.

Thank you for clarification. That makes sense, we’ll try to support this use case in the future.
Created issue: https://youtrack.jmix.io/issue/JST-5525/Partial-reverse-engineering-of-existing-entity-tables.

1 Like