3 Replies Latest reply on Mar 7, 2007 9:02 AM by hanasaki jiji

    howto? new entity persist with aggregates that are already p

    hanasaki jiji Newbie

      JBoss 4.0.5 - EJB3 - Entity Beans

      ** The problem is - the foreign key column is not set on the newInstance Row. thus the inserted value is NULL.

      There is an new instance of a class that is being worked on as follows:

      aggregate = // retrieve / find in database - ie: already persisted
      newInstance = new NewInstance();

      newInstance is saved, as a new row, in the RDBMS just fine; however, the aggregate_fk (see below for table) is set to null - actually I think it is not even in the insert statement.

      NewInstance.get/setValue are defined below:
      @JoinColumn(name="aggregate_fk", insertable=false, updatable=false, referencedColumnName="pk")
      public Aggregate getValue() { return aggregate; }

      NewInstance Table (Pseudo Notation for sql)
      integer pk
      char(10) column1
      integer aggregate_fk -- foreign key reference to aggregate table

      Aggregate is actually a lookup table as below
      integer pk
      char(15) key
      varchar(64) value

      *Note: this table is referenced by many other tables in the system; therefore, it cannot contain annotations of OneToMany (etc..) to a specific other table.