Q: JPA. What kind of relation to use between two entities. (Can't remove record from one entity) I'm writing to you after looking for some info, but as English is nt my first language I might have missed the answer for my problem.
Description:
I have a two entities. Say one of them is User, and the other one is UsersAttributes.
User will look like this:
@Entity
@NamedQueries({
    //some queries
})
public class User implements Serializable
{

    @Id
    @GeneratedValue(strategy= GenerationType.AUTO)
    private Long id;
    @ManyToMany
    private List<UserAttributes> attributes;

    //getters, setters, constructors, equals, hashCode..
}

And then there is the UserAttributes entity:
@Entity
@NamedQueries({
    //some queries
})
public class UserAttributes implements Serializable
{
    @Id
    @GeneratedValue(strategy= GenerationType.AUTO)
    private Long id;

    @NotNull
    private String Name;
    //getters, setters, constructors, equals, hashCode..
}

And the effect that I want to have is:
The User is the owning side of the relationship.
The UserAttributes is (I don't know if I'm calling it right) a dictionary - values from this entity can be user by any object of User entity. For e.g.
user1  has UserAttributes 1,2
user2  has UserAttributes 2,3
user3  has UserAttributes 1,2,3
user4  has no UserAttributes

(I would like the UserAttributes records to be reusable)
The code taht I've written is working well,the values between entities are assigned well, but 
When I want to remove a record from UserAttributes I can't do it if it is already 
in possesion of some User. How to solve this, what kind of mapping I should use, 
should I used **cascade** attribute, and how to do this?


A: First of all thanks
JB Nizet
for comments.
I think Ive solved it by using mappedBy attribute. In UserAttributes I've added this:
@ManyToMany(mappedBy="attributes")
private List<User> users;

And in User I didn't change anything. Now I can remove attributes "irrespectively" from User entity, and the change is propagated on all the records, and there's no exceptions.
