Related unresolved issue on GitHub: https://github.com/quarkusio/quarkus/issues/40006
I define my entity with following structure:
package org.example.crud;
import java.util.UUID;
import io.quarkus.hibernate.orm.panache.PanacheEntityBase;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.validation.constraints.Pattern;
@Entity
public class MyEntity extends PanacheEntityBase {
@Id
@Column(name = "id")
@GeneratedValue(strategy=GenerationType.UUID)
private UUID id;
@Pattern(regexp = "^[A-Z0-9]{3}$")
public String code;
}
And according to Repository Pattern I created Resource Interface and Repository:
package org.example.crud;
import jakarta.enterprise.context.ApplicationScoped;
import java.util.UUID;
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
@ApplicationScoped
public class MyEntityRepository implements PanacheRepositoryBase<MyEntity, UUID> {
}
package org.example.crud;
import java.util.UUID;
import io.quarkus.hibernate.orm.rest.data.panache.PanacheRepositoryResource;
public interface MyEntityResource extends PanacheRepositoryResource<MyEntityRepository, MyEntity, UUID> {
}
When I build app and go to Swagger UI I got and ID field on entity creation request instead just other fields because it is meaningless to have a generated ID in DB and provide it via REST API.
What should I do to resolve this issue? Is there a native Quarkus/Jakarta/Hibernate Ecosystem solution or should I define MyEntityCreateDTO
or some kind of mapping instead? Maybe something else.
I am completely new to Java/Quarkus and got no enterprise development experience.