How do I make a OneToMany Unidirectional relationship with joincolumn mandatory? [closed]

1

How do I make this relationship mandatory when em.persist () is run?

I do not want to bidirectional map.

@OneToMany(cascade = {CascadeType.ALL})
@JoinColumn(name = "cliente_id",referencedColumnName="ID",insertable=true, nullable=false, columnDefinition="bigint DEFAULT 1 NOT NULL")
public List<Telefone> getTelefones() {
    return telefones;
}
    
asked by anonymous 16.08.2016 / 20:39

1 answer

1

This question does not contain Entities. Well, in this case just do not create any attribute in the Phone class. As it is in your code, you are saying that this class (not specified in the question) has several phones. As it is, it is already unidirectional, if you have not declared any attribute of this class (not specified in the question) in the Phone class.

    
26.08.2016 / 16:03