I have two Java Entites Obj and Trt for two tables in DB obj ( ID, ID_TRT,...) and trt(ID,...) defined as following:
@MappedEntity("obj")
public class ObjEntity{
...
private TrtEntity trt;
...
@Nullable
@MappedProperty("ID_TRT")
@JoinColumn(name ="ID_TRT")
@Relation(value = Relation.Kind.MANY_TO_ONE)
public TraitementEntity getTrt() {
return trt;
}
public void setTrt(final TrtEntity trt) {
this.trt= trt;
}
...
}
@MappedEntity("trt")
public class TrtEntity{
private Long id;
private List<ObjEntity> objs;
....
@Relation(value = Relation.Kind.ONE_TO_MANY, mappedBy = "trt", cascade = { Relation.Cascade.ALL })
public List<ObjEntity> getObjs() {
return objs;
}
...
}
In a class, we call a method ObjRepository.findAll(...), which should execute the following SQL query:
select ID, ID_TRT, .... from obj where ...
Sometimes we get this query, but sometimes we have :
select ID, TRT_ID, .... from obj where ...
The problem is that ID_TRT becomes TRT_ID in generated query by Micronaut Data
Any idea?