-
1. Re: Database triggers and entity beans
busitech Oct 19, 2006 7:28 PM (in response to sbivol)Please let us know if you find a nice way to do this. This limitation of not being able to use the entity manager during callbacks is really a problem!
We are trying to find a clean way to set up simple calculated properties of an object which are assigned a value automatically when it is loaded, such as the sum total of one column, or even a count, from objects on the other side of a OneToMany association.
A concrete example would be to add a YTDSales property to a Salesman object, or an ItemCount property to a Manufacturer object.
There is a @Formula annotation which can contain an SQL string, and the docs state that a subselect can even be performed. However, we would really prefer to stay in Java working with objects! -
2. Re: Database triggers and entity beans
laszlo.fogas Oct 21, 2006 10:18 AM (in response to sbivol)hi,
in an other topic i asked amost the same.. others offered me to use @resource annotation, or sg like that, but before that i do a simple jndi lookup to get the entitymanager. You have to put some properties into the persistence.xml jndiname or sg, and after you can get the manager. Please take care that your transaction is works perfectly! I tested it only once, and when i throw an exception during the callback method, it seems that stoped the transaction.
lazlo