Sunday, 15 April 2012

java - hibernate filter using field from superclass -



java - hibernate filter using field from superclass -

i trying migrate application jboss 7.1.1 using hibernate 4.0.1.final jboss eap 6.2 uses version 4.2.7.sp1.

i have next hierarchy of entities:

@mappedsuperclass @filters({ @filter(name = "deleted") }) @filterdef(name = "deleted", defaultcondition = "deleted null") @inheritance(strategy = inheritancetype.joined) public abstract class base of operations implements serializable { @id @generatedvalue private long id; @temporal(temporaltype.timestamp) private date deleted; // getters/setters... } @entity @table(name = "actors")) @inheritance(strategy = inheritancetype.joined) public class actor extends base of operations { private string name; // getters/setters... } @entity @table(name = "users") public class user extends actor { private string firstname; private string lastname; // getters/setters... }

i want app filter out objects having 'deleted' property set non-null value , purpose utilize hibernate filters:

session.enablefilter("deleted"); list<?> list = session.createquery("from user").list(); // list contains users deleted == null

on hibernate 4.0.1 works fine. when run on newer version next error:

error: error: column user0_.deleted not exist position: 211

during research found first version breaks code - 4.1.5.sp1. found potentialy related enhancement:

https://hibernate.atlassian.net/browse/hhh-2394

is bug (possibly introduced in 4.1.5.sp1 , not fixed until now, i.e. 4.3.5.final) or there another, more recommended way implement feature?

java hibernate

No comments:

Post a Comment