Bug 364 : Delete getting ... SQLException:ERROR: column t0.null does not exist
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
2.7.3
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
23/03/2011
Updated 
23/03/2011
Type 
Bug
 
Attachments 
No attachments

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=?

 
Rob 23 Mar 08:23
The issue

The issue here was the expression for the foreign key was being incorrectly resoved.

Rob 23 Mar 08:25
Fixed in HEAD

Fixed in HEAD.

woResponse

Upload a file