1

We have migrated our project to use the latest version of hibernate which is 4.1.6 and seam which is 3.2 and JPA 2.1 . We Are having problem with the @Formula annotation. It seems that the right SQL is executed from the SQL output but the property value returns null. I dont know if these is dependency issue or anything. If you guys know it will be a big help

Here is the snapshot of the property.

@Formula(value="(select crs.name from EntityName crs where crs.id = id)")
public String getName() {
    System.out.println(" name set -- " + name);
    return name;
}

Many Thanks.

Ellie Fabrero
  • 791
  • 2
  • 16
  • 41
  • 1
    The Formula annotation supports SQL only. You seem to be attempting to use HQL. – JamesB Jul 07 '14 at 11:07
  • It works with [HQL](http://stackoverflow.com/questions/2986318/calculated-property-with-jpa-hibernate) too. Is the @Id set to a getter too, right? If you are using property-access you need to have all mapping annotations applied to properties. – Vlad Mihalcea Jul 07 '14 at 13:31
  • This code actually works when using hibernate 3.x version, now when we use version 4 it does not set the value anymore. All of our property with @Formula does not work. – Ellie Fabrero Jul 08 '14 at 01:24
  • 1
    I am having the same problem, over a year later. Did you ever find a solution? – user1944491 Aug 23 '15 at 20:19
  • No i havent, fortunately we did not pursue with the migration. :) – Ellie Fabrero Aug 25 '15 at 09:11
  • Too bad. We have the same issue :( – Shervin Asgari Apr 07 '16 at 10:18
  • I haven't found any thing related to this anymore and i have not tried it either so far. If you managed to find out something, please post it here, it will help others too. Thank you. :) – Ellie Fabrero Apr 08 '16 at 02:53

0 Answers0