4 Replies Latest reply on Apr 3, 2006 6:57 AM by oliverchua

    Recursive Bidirectional entity

    oliverchua Newbie


      public class Unit implements Serializable{
       @Id @GeneratedValue
       private Long unitCode;
       private String unitName;
       @ManyToOne @JoinColumn(name="superUnitCode")
       private Unit superUnit;
       private Set<Unit> subUnits;
       private String superUnitCode;

      Hi I have this entity class.
      The OneToMany is bidirectional and recursive.
      IT adds
      CONSTRAINT `FK284DA4E626B09B` FOREIGN KEY (`unitCode`) REFERENCES `unit` (`unitCode`)
      that prevents any inserts to the table.

      What should I do to remove the constraint?
      Thanks in advance.