2 Replies Latest reply on Oct 10, 2007 6:43 PM by yacho

    inserting into associations..

      How should I insert into associations.

      Let's say I have the following tables..

      create table user (
      user_id bigint unsigned NOT NULL,
      user_name varchar(255) NOT NULL,
      PRIMARY KEY(user_id)
      );

      create table actions (
      action_id tinyint unsigned not null,
      action_name varchar(255) NOT NULL,
      PRIMARY KEY(action_id));

      create table user_actions (
      user_id bigint unsigned not null,
      action_id tinyint unsigned NOT NULL,
      session_id varchar(255),
      action_time TIMESTAMP NOT NULL,
      PRIMARY KEY (user_id, action_id, session_id, action_timestamp)
      FOREIGN KEY(user_id) REFERENCES user(user_id) ON UPDATE CASCADE ON DELETE RESTRICT,
      FOREIGN KEY(action_id) REFERENCES actions(action_id) ON UPDATE CASCADE ON DELETE RESTRICT);

      Lets say the user record exists and the action record exists. What is the way to insert a record into user_actions.

      If I try to persist a UseractionsAssocHome object obtained from Component.getInstance, I get a EntityNotFound exception.

      Caused by: org.jboss.seam.framework.EntityNotFoundException: entity not found: c
      om.foo.entity.UserActionAssoc#com.foo.entity.UserActionAssocId@6bca1c13
      at org.jboss.seam.framework.Home.handleNotFound(Home.java:109)
      at org.jboss.seam.framework.EntityHome.find(EntityHome.java:75)
      at org.jboss.seam.framework.Home.initInstance(Home.java:91)
      at org.jboss.seam.framework.Home.getInstance(Home.java:71)
      at org.jboss.seam.framework.EntityHome.persist(EntityHome.java:50)
      at com.foo.entity.UserActionAssocHome.persist(UserActionAssocHome.jav
      a:29)

      Thanks,

      M