Hi,
using a single table inheritance strategy with postgres 7.3 always causes a ConstraintViolationException when I try to merge the changes.
I first create a new enity bean, which works. Then I add it to a OneToMany collection of another entity bean and try to merge the change. This is when I get a ConstraintViolationException.
Here is the setup:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Person implements Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
long id;
..
}
@Entity
@Name("junior")
public class Junior extends Person
{
...
}
@Entity
@Name("school")
public class School implements Serializable
{
@Id
@NotNull
@Length(min = 5, max = 40)
String schoolName
@OneToMany(cascade = {CascadeType.ALL})
List<Juniors> juniors = new ArrayList<Juniors>();
@OneToMany(cascade = {CascadeType.ALL})
List<Softmore> softmores = new ArrayList<Softmore>();
@OneToMany(cascade = {CascadeType.ALL})
List<Senior> seniors = new ArrayList<Senior>();
...
// works entityManager.persist(junior); // this causes a contraint violation school.getJuniors().add(junior); school = entityManager.merge(rewriteConfiguration);
school_schoolname character varying(40) NOT NULL juniors_id bigint NOT NULL softmores_id bigint NOT NULL seniors_id bigint NOT NULL