4 Replies Latest reply on Apr 13, 2007 2:50 AM by Patrick Krämer

    Question @Inheritance

    Patrick Krämer Newbie

      Well it's me again with a question for using @Inheritance

      Well I got one super Entity:

      @SequenceGenerator(name = "user_sequence", sequenceName = "user_id_seq")
      public class User implements Serializable {
       private static final long serialVersionUID = 1487970457796785528L;
       @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_sequence")
       private Long id;

      and a child class

      public class RegisteredUser extends User implements Serializable{
       private static final long serialVersionUID = 2027308984532828735L;

      with no specific id.

      Both entities are represented by an own table. The Primary Key from the parent table is also used as primary key in child table (mapped with foreign key)

      When I try to persist a child object I got an Error:

      18:19:46,968 ERROR [JDBCExceptionReporter] ERROR: insert or update on table "registered_user" violates foreign key constraint "fk22ff4768223777df"
      Detail: Key (u_id)=(1600) is not present in table "users".
      18:19:46,968 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session

      How can I tell the manager to persist the attributes in my parent table? Perhaps with cascade strategy? And where should I put it?

      Thx a lot