Modeling "user status" relationships

From: Robert Zeigler (rdzeigl...arizona.edu)
Date: Mon Jun 28 2004 - 21:47:27 EDT

  • Next message: Tore Halset: "adding postgresql data types"

    Hi,

    I have a User db entity/object and a UserStatus entity/object. The User
    db entity has a status attribute that maps to a userStatus primary key.
    There should be a finite number of rows in the UserStatus db entity
    corresponding to the possible statuses a user may be set to. What's the
    best way to set this up so that I can create a new user and set the
    status to a certain status without cayenne trying to create a new status
    row for that status?
    eg:
    possible user statuses:
    normal and privileged.
    Create user a and set status to normal. Create user b and set status to
    normal; currently, I'm creating and registering a new UserStatus object
    with each user, but that ends up throwing a duplicate primary key
    exception. Should I run a query to pull out the desired status from the
    db and set the user status to /that/ object so that cayenne knows that
    the desired UserStatus already exists in the UserStatus db entity?
    Thanks for any help!

    Robert



    This archive was generated by hypermail 2.0.0 : Mon Jun 28 2004 - 21:48:01 EDT