ObjectDB ObjectDB

ManyToMany Set is null

#1

Why can the field "contracts" be "null"?

----------

@Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)

public class Person implements Serializable,Subject {

    @Id @GeneratedValue

    private long id;

    @ManyToMany(fetch = FetchType.EAGER, cascade={CascadeType.DETACH,CascadeType.MERGE,CascadeType.REFRESH}) @JoinTable(name="PERSON_CONTRACT")

    private Set<Contract> contracts = new HashSet<Contract>();

----------

@Entity

public class Contract {

    @Id @GeneratedValue

    private long id;

    @ManyToMany(fetch = FetchType.EAGER, cascade={CascadeType.DETACH,CascadeType.MERGE,CascadeType.REFRESH}, mappedBy = "contracts")

    private Set<Person> persons = new HashSet<Person>();

[...]

edit
delete
#2

There could be various reasons (e.g. maybe Person objects have been created and persisted with a previous version of the Person class, in which the contracts fields was not initialized).

More information is needed in order to answer your question.

Please post a minimal program in this format that demonstrates the scenario.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.