Hi,
I've been doing some tests on how Ebean performs simple operations
(find, save, delete) on my updated data model and everything works
fine except delete.
Consider simple data model:
@Entity
@Table(name="car")
public class Car extends EntityBean {
@Id @GeneratedValue(strategy = GenerationType.SEQUENCE)
protected Long id;
@Version
private int version;
@OneToMany(mappedBy = "car", cascade = CascadeType.ALL)
private List wheels;
....
}
@Entity
@Table(name="wheel")
public class Wheel extends EntityBean {
@Id @GeneratedValue(strategy = GenerationType.SEQUENCE)
protected Long id;
@Version
private int version;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name="tire")
private Tire tire;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "car")
private Car car;
....
}
@Entity
@Table(name="tire")
public class Tire extends EntityBean {
@Id @GeneratedValue(strategy = GenerationType.SEQUENCE)
protected Long id;
@Version
private int version;
....
}
I have an entry in DB that was created with code:
Car car = new Car();
Tire t1 = new Tire();
Wheel w1 = new Wheel();
w1.setCar(car);
w1.setTire(t1);
Tire t2 = new Tire();
Wheel w2 = new Wheel();
w2.setCar(car);
w2.setTire(t2);
Tire t3 = new Tire();
Wheel w3 = new Wheel();
w3.setCar(car);
w3.setTire(t3);
Tire t4 = new Tire();
Wheel w4 = new Wheel();
w4.setCar(car);
w4.setTire(t4);
Ebean.save(car);
And I'm trying to delete this entry with code:
Car car = Ebean.find(Car.class, 1);
Ebean.delete(car);
The problem is that it generates SQL that refers to some null column
(SQL taken from transaction log):
select t0.id as c0 from wheel t0 where t0.null=?
Obviously it ends up with an exception:
javax.persistence.PersistenceException: Query threw
SQLException:ERROR: column t0.null does not exist
Bind values:[1, ]
Query was:
select t0.id as c0
from wheel t0
where t0.null=?