Hallo,
Ich arbeite mit JPA d.h. Java Persistence API mit dem sogenannten TopLink von Netbeans (Java Binding). Mit EntityManager.getTransaction().commit() kann ich ja die gemachten Änderungen in die DB committen bzw. speichern. Nun will ich aber vorher wissen, welches Data Bean sprich Entity-Bean geändert wurde und die Frage stellt sich, wie ich ein geändertes Bean ermitteln kann. Ich brauche diese Information da ich gewisse Werte im Bean manuell setzen muss bevor es mit commit() in die DB zurückgeschrieben wird...
Ich hoffe, diese Infos helfen weiter.
Hm... ich denke wir haben sehr verschiedene Begrifflichkeiten.
Was für mich eine Entity-Bean ist: http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/EJBConcepts4.html
Dabei:
"With bean-managed persistence, the entity bean code that you write contains the calls that access the database. If your bean has container-managed persistence, the EJB container automatically generates the necessary database access calls. The code that you write for the entity bean does not include these calls."
Worauf en ankommt: in einem Bean ändert man nichts (im Endeffekt ist das ja eine Klasse) und manuell schon gar nicht.
Daher weiss ich nicht was du genau meinst.
Wenn du eine Instanz eines Beans meinst, die mit den persistenten Daten erzeugt und vom EntityManager verwaltet wird, dann reden wir hier über Transkationen und vermutlich über "Optimistic Locking".
Die EJB 3.0 Spez. (http://cds-esd.sun.com/ESD24/JSCDL/ejb/3.0-fr/ejb-3_0-fr-spec-persistence.pdf) sagt dazu (Punkt 3.4):
"Optimistic locking is a technique that is used to insure that updates to the database data corresponding to the state of an entity are made only when no intervening transaction has updated that data for the
entity state since the entity state was read. This insures that updates or deletes to that data are consistent with the current state of the database and that intervening updates are not lost."
Und um das Problem zu lösen gibt's das Version Attribut.
"Portable applications that wish to enable optimistic locking for entities must specify Version attributes for those entities—i.e., persistent properties or fields annotated with the Version annotation or specified in the XML descriptor as version attributes."
Grüße
Thomas