Good morning, I have a problem with the design of tables and I would like to know your opinion. I have a table from another system incorporated with Generate Model, this table has a composite primary key, it also has two relationships, one ManyToOne and another OneToOne, my problem is that the OneToOne relationship loads perfectly but the ManyToOne I am not able to do it, I expose this table called Ubica
unmappedColumns = {"feculten", "exultinv", "fecultin", "exantult", "pvenult", "marcainv", "prem", "prov", "fecsurti", "existcj", "exultincj", "exantulcj", "diasped"})
@Table(name = "ubica")
@Entity(name = "athia_Ubica")
public class Ubica extends BaseGenericIdEntity<UbicaCompKey> {
private static final long serialVersionUID = 5042927591595894782L;
@EmbeddedId
private UbicaCompKey id;
/*
@ManyToOne (fetch = FetchType.LAZY)
@JoinColumn(name = "refe", referencedColumnName = "refe", insertable = false, updatable = false)
private Almacen almacen;
*/
@SystemLevel
@Column(name = "refe")
private String refe;
@Transient
@MetaProperty(related = "refe")
private Almacen almacen;
@OneToOne (fetch = FetchType.LAZY)
@JoinColumns({
@JoinColumn(name = "refe", referencedColumnName = "refe", insertable = false, updatable = false),
@JoinColumn(name = "ubic", referencedColumnName = "ubic", insertable = false, updatable = false)
})
private Ubiccomp ubiccomp;
As I said before, when I make a view and I put the relation OneToOne, this one is loaded perfectly, but the ManyToOne does not do it in spite of being in the view. I have tried in two ways, as it is seen in the code I have also tried with the commented part, I have not been successful either.
Next the class of primary key of the class Ubica
@DdlGeneration(value = DdlGeneration.DbScriptGenerationMode.CREATE_ONLY)
@MetaClass(name = "athia_UbicaCompKey")
@Embeddable
public class UbicaCompKey extends EmbeddableEntity {
private static final long serialVersionUID = 6045265313894742496L;
@Column(name = "refe", length = 16)
private String refe;
@Column(name = "ubic", length = 6)
private String ubic;
Now the class that represents the relation One in ManyToOne
unmappedColumns = {"correspond", "descorta", "fechalta", "ultpreco", "ultpredi", "precostm", "precvent", "tipoenva", "marcaofe", "existini", "existsal", "existota", "cantpend", "ultcantd", "existsaa", "feciltin", "existult", "marcainv", "netiquet", "marcasin", "huecosv", "precven2", "dcto", "comp", "averias", "puntos", "desc2", "descorta2", "premnetn", "ultprene", "balafeti", "balatxt1", "balatxt2", "balatxt3", "balaing1", "balaing2", "balaing3", "ultfcad", "ctrlcaja", "precvmin", "empr", "refealte", "envaseun", "envasecj", "envasecg", "intrastat", "enlazado", "grupotr", "tpalet", "alcohol", "ctaric", "codresti", "porresti", "criterio1", "criterio2", "criterio3", "modelo", "coprefer", "faccanal", "fmto2", "worden", "wdesta", "wdesven", "precvsin", "unidaux", "pesoaux", "wdespub", "envasepl", "modopre", "mermnata", "congruen", "eticaja"})
@Table(name = "almacen")
@Entity(name = "athia_Almacen")
@NamePattern("%s|descripcion")
public class Almacen extends BaseStringIdEntity {
private static final long serialVersionUID = 2086429465635738582L;
@Id
@Column(name = "refe", nullable = false, length = 16)
private String refe;
@OneToOne(fetch = FetchType.LAZY)
@MapsId
@JoinColumn(name = "refe")
private Articomp articomp;
ยดยดยด
Here I do not define any relationship with the Many part because I do not need to access it from here, there is another relationship OneToOne but it is with another table, and this one loads perfectly.
Any suggestions?
Thank you and best regards.
Platform version 7.2.11, CUBA Studio version 15, IntelliJ 2020.2