Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Virtual columns (@Formula of Hibernate)
Virtual columns (@Formula of Hibernate) [message #500349] Wed, 25 November 2009 17:41 Go to next message
Adrian Gygax is currently offline Adrian Gygax
Messages: 14
Registered: July 2009
Junior Member
Hi!

Does anybody know if EclipseLink has an equivalent to Hibernate's @Formula ( http://docs.jboss.org/hibernate/stable/annotations/reference /en/html/entity.html#d0e2273)?

I would like to automatically populate the "currentPrice" attribute of a "Product" entity with the price valid for today which has to be reat from another database table.
Re: Virtual columns (@Formula of Hibernate) [message #500532 is a reply to message #500349] Thu, 26 November 2009 14:36 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

There is no direct equivalent (please log an enhancement), but depending on what you want to do, there are ways to accomplish the same thing.

EclipseLink defines a TransformationMapping which can map a computed value from multiple field values, or access the database.

You can override the SQL for any CRUD operation for a class using its descriptor's DescriptorQueryManager.

You could define a VIEW on your database that performs the function and map your Entity to the view instead of the table.

You can also perform minor translations using Converters or property get/set methods.


James : Wiki : Book : Blog : Twitter
Re: Virtual columns (@Formula of Hibernate) [message #500637 is a reply to message #500349] Fri, 27 November 2009 09:27 Go to previous message
Adrian Gygax is currently offline Adrian Gygax
Messages: 14
Registered: July 2009
Junior Member
Hi James, thanks for your hints. I think I can do what I want with one of the options you mentioned, I just have to select the best one for my case Smile

I filed an enhancement request for having the easy to use @Formula feature in EclipseLink as well:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=296324
Previous Topic:Why does weaving prevent initalization of class variable
Next Topic:How to set JDBC fetch size on JPA query?
Goto Forum:
  


Current Time: Sun Sep 21 00:19:24 GMT 2014

Powered by FUDForum. Page generated in 0.10305 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software