Issue Details (XML | Word | Printable)

Key: BSHD-5
Type: Bug Bug
Status: In Progress In Progress
Priority: Major Major
Assignee: Gabriele Catania
Reporter: Gabriele Catania
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Base spring/hibernate DAO

find filtered does not work with embeddable fields

Created: 13/Oct/09 10:28   Updated: 09/Jun/10 19:20
Component/s: None
Affects Version/s: 2.0.5
Fix Version/s: None


 Description  « Hide

if an entity class has a property of type embeddable, when trying to filter by a property of the embedded property, hibernate attempts to filter by a nonexistent property of the parent entity and throws an exception
example:

@Entity
public class Foo {
    private Bar bar;
    public Bar getBar() {return bar;}
    public void setBar(Bar bar) {this.bar = bar;}
}

@Embeddable
public class Bar {
    private String baz;
    public String getBaz() {return baz;}
    public void setBaz(String baz) {this.baz = baz;}
}

Foo filter = new Foo();
Bar bar = new Bar();
bar.setBaz("baz");
filter.setBar(bar);
FooDAO.findFiltered(filter);

yields the following:

org.hibernate.QueryException: could not resolve property: baz of: Foo



Gabriele Catania added a comment - 23/Apr/10 10:09 - edited

It appears to occur also for properties marked with @Transient and/or setter methods that do not correspond to an actual persisted field. Example:

@Entity
public class Foo {
  private Bar bar;
  public Bar getBar() {return bar;}
  public void setBar(Bar bar) {this.bar = bar;}
  public void setBar2(Bar bar2) {this.bar = bar2;}
}

Foo foo = new Foo();
foo.setBar(new Bar());
fooDAO.findFiltered(foo);

yields:

org.hibernate.QueryException: could not resolve property: baz2 of: Foo


Gabriele Catania added a comment - 07/Jun/10 10:32

Committed a proposed fix (still work in progress, need to implement some functionality like filterMetadata support) with revision 2623 (sorry, wrong issue number in commit message)