Faced a problem when creating classes from a database. When generating, if you check the client_id field and the one-to-many connection for this type field, then a code of the following type is generated:
@Basic @Column(name = "client_id", nullable = false) public int getClientId() { return clientId; } public void setClientId(int clientId) { this.clientId = clientId; } @ManyToOne @JoinColumn(name = "client_id", referencedColumnName = "id", nullable = false) public ClientEntity getClientByClientId() { return clientByClientId; } public void setClientByClientId(ClientEntity clientByClientId) { this.clientByClientId = clientByClientId; } This causes a failedorg.hibernate.MappingException: Repeated column in mapping for entity: com.tr1nksgroup.model.data.entities.ReturnEntity column: client_id (should be mapped with insert="false" update="false") error failedorg.hibernate.MappingException: Repeated column in mapping for entity: com.tr1nksgroup.model.data.entities.ReturnEntity column: client_id (should be mapped with insert="false" update="false") What actually logical and correct. But I need to have a setter id number and a setter entity. Is it possible?
@Column(name = "client_id", insertable=false, updatable=false)- Sergeyinsertable=falsesays that the column is not included in theINSERTwhich is generated by the provider - Tr1nksclientByClientIdmapping. By the way, in order not to pull a large entity, you can try to get an instance ofClientEntityusing anEntityManager.getReference. Such an instance will be loaded in a lazy way. - Sergey