2 Replies Latest reply on Feb 22, 2006 11:17 AM by bbreil

    import.sql

    bbreil

      Hello

      I'm using the dvd-example and I tried to create two EntityBeans like Order and OrderLine with a OneToMany Relationship.




      @Entity
      @Name("bpath")
      @Scope(EVENT)
      public class Path implements Serializable{

      private int pathId;
      private String pathName;
      private List <PathTerm> pathTerms = new ArrayList <PathTerm> ();

      @Id @GeneratedValue
      @Column(name="PATHID")
      public int getPathId() {
      return pathId;
      }
      public void setPathId(int pathId) {
      this.pathId = pathId;
      }

      @NotNull
      public String getPathName() {
      return pathName;
      }
      public void setPathName(String pathName) {
      this.pathName = pathName;
      }

      @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy ="referPath")
      @JoinColumn (name = "PATHID")
      public List<PathTerm> getPathTerms() {
      return pathTerms;
      }
      public void setPathTerms(List<PathTerm> pathTerms) {
      this.pathTerms = pathTerms;
      }


      public void addPathTerm(String text) {
      if (pathTerms == null)
      pathTerms = new ArrayList<PathTerm>();

      PathTerm pathTerm = new PathTerm();
      pathTerm.setText(text);
      pathTerm.setReferPath(this);

      pathTerms.add(pathTerm);
      }

      }





      @Entity
      @Name("pathterm")
      public class PathTerm implements Serializable {

      int pathTermId;
      int frequency;
      int totalNumber;
      String text;
      String dfrequency;
      Path referPath;


      @Id @GeneratedValue
      @Column(name="PATHTERMID")
      public int getPathTermId() {
      return pathTermId;
      }
      public void setPathTermId(int pathTermId) {
      this.pathTermId = pathTermId;
      }


      public String getDfrequency() {
      return dfrequency;
      }
      public void setDfrequency(String dfrequency) {
      this.dfrequency = dfrequency;
      }


      public int getFrequency() {
      return frequency;
      }
      public void setFrequency(int frequency) {
      this.frequency = frequency;
      }


      @ManyToOne
      @JoinColumn (name = "PATHID")
      public Path getReferPath() {
      return referPath;
      }
      public void setReferPath(Path referPath) {
      this.referPath = referPath;
      }

      public int getTotalNumber() {
      return totalNumber;
      }
      public void setTotalNumber(int totalNumber) {
      this.totalNumber = totalNumber;
      }
      public String getText() {
      return text;
      }
      public void setText(String text) {
      this.text = text;
      }

      }



      Furthermore I use the import file with these two statements

      insert into PATH (PATHID, PATHNAME) VALUES (1, 'PATH 1')
      insert into PATHTERM (PATHTERMID, PATHID, TEXT, FREQUENCY, DFREQUENCY, TOTALNUMBER) VALUES (1, 1, 'myText', 2, 'anotherText', 3)



      I get this exception and have no idea, what's wrong



      Caused by: java.sql.SQLException: Integrity constraint violation FKD5F177D4B4327F2A table: TERMINE
      at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
      at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source)
      at org.hsqldb.jdbc.jdbcStatement.execute(Unknown Source)
      at org.jboss.resource.adapter.jdbc.WrappedStatement.execute(WrappedStatement.java:82)
      at org.hibernate.tool.hbm2ddl.SchemaExport.importScript(SchemaExport.java:251)


        • 1. Re: import.sql
          patrick_ibg

          What is the table named "TERMINE"? Does it have relationships with PATH or PATHTERM?

          • 2. Re: import.sql
            bbreil

            im sorry

            TERMINE has to be PATHTERM

            I've tried another example too and postet the wrong error report

            But it's the same

            PATH 1 ---- * PATHTERM

            or

            KATALOG 1 ----* TERMINE