Hi Patrick, thanks for your response. Good idea to use the class itsself instead of an external EntityListener (didn't know that works -- I am new to JPA).
However, is it really such a strange thing I want to do? A class that has all its fields properly filled when loaded but without each field directly (1:1) mapped to a database but instead "calculated/fetched" on the fly (at load time)? As far as I understand, I only have two options: 1. Put the logic to obtain the currentPrice up one layer in a SLSB or 2. Use OpenJPAPersistence.getEntityManager(fund) which is non-standard Hm, I don't like option 1 at all. That would mess up my design as a Fund is then no longer self contained (either the Fund itsself or the client would always have to call the SLSB). So, I will probably go with option 2. Thanks a lot, Patrick! I didn't know that option exists. But, shouldn't there be a more portable standard (spec) way to do this? I can easily think of several cases in my application where I could use this. How do other people (probably without OpenJPA) solve this issue? Chris Patrick Linskey-2 wrote: > > Hi, > > The spec doesn't provide a means to do what you're looking for, but > OpenJPA does -- you can call OpenJPAPersistence.getEntityManager(o) to > obtain the entity manager for a given object. > > Also, it might be useful to use entity callbacks defined in the entity > class itself instead of external listeners, from a programming > standpoint. You can do this by just annotating a method in your Fund > class with @PostLoad etc. > > -Patrick > > -- > Patrick Linskey > 202 669 5907 > > -- View this message in context: http://www.nabble.com/EntityManager-in-EntityListener-tf4524285.html#a12921837 Sent from the OpenJPA Users mailing list archive at Nabble.com.
