I am trying to create a column 'Barcode' which is to be the primary key and of type string.
this is what i am doing :
// for table-one
@Id
@Column(name = "BARCODE", nullable=false)
private String barcode;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "BARCODE")
private List<Doc_Mvmnt> doc_mvmnt = new ArrayList<>();
and in another where table-one will have one to many mapping
//for table-two
@ManyToOne
@JoinColumn(name = "BARCODE", nullable=false)
public String barcode;
I am recieving the exception :
Exception in thread "main" org.hibernate.AnnotationException: @OneToOne or @ManyToOne on database.Doc_Mvmnt.barcode references an unknown entity: java.lang.String