I write a simple test but I have got an arrset error (nature.sets =
null)
@Entity
@Table(name = "natures")
public class Nature extends Model {
@Required
@MaxSize(64)
@Column(length = 64)
public String name;
@OneToMany(mappedBy = "companyNature", fetch = FetchType.LAZY,
cascade = { CascadeType.PERSIST, CascadeType.MERGE,
CascadeType.REMOVE })
public List<Set> sets;
}
@Entity
@Table(name = "sets")
public class Set extends Model {
/**
* The name for the set. Permits to have significative info in error
messages.
*/
@Required
@MaxSize(64)
@Column(length = 64)
public String name;
/**
* If this set is associated with a company nature it will be
contained in
* that list.
*/
@ManyToOne(fetch = FetchType.LAZY)
public Nature Nature;
}
@Test
public void testDeleteNature() {
Nature c = newNature();
c.name = "Gambling2";
c.save();
Set set = new Set();
set.name = "test";
set.nature = c;
set.save();
Nature nature = Nature.find("byName", "Gambling2").first();
assertNotNull(nature );
assertNotNull(nature.sets);
assertTrue(nature .sets.size() > 0);
Does somebody has some idea about the problem ?