This content has been marked as final.
Show 2 replies
-
1. Re: how to make a ejbql query from an entity bean ?
pmuir Dec 3, 2007 6:03 AM (in response to vlaugier)Its not good practice to do this (I'm sure Gavin has some blogs on this, so go look on http://in.relation.to) but if you have to you would have to look up the EM programatically.
-
2. Re: how to make a ejbql query from an entity bean ?
supernovasoftware.com Dec 3, 2007 12:15 PM (in response to vlaugier)I use @Formula. It requires compile time instrumentation for lazy loading and will not load collections unless you use hibernate mapping files. It works fine with calculated properties and annotations as shown below.
See:
http://opensource.atlassian.com/projects/hibernate/browse/ANN-210
It works well and you can even use the properties in HQL.
Example:private Double baseCostPerFt; @Basic(fetch = FetchType.LAZY) @Formula(value="( select v.basecostperft from v_item_calc v where v.id = id )") public Double getBaseCostPerFt() { return baseCostPerFt; } public void setBaseCostPerFt(Double baseCostPerFt) { this.baseCostPerFt = baseCostPerFt; }
HQL:select i from Item i where i.baseCostPerFt>10.59