Lifecycle « Core « JPA Q&A





1. Validating Jpa Entities: In service or by lifecycle listeners    stackoverflow.com

The question is where it is better (or in other words: where do you prefer) to put business validation logic of Jpa Entities. Two ideas are:

  1. In the EntityListener that before save or ...

2. JPA 2.0 + IBatis . JPA Lifecycle appliance    stackoverflow.com

I have class mapped with JPA 2.0 (class A) which has list of objects of class B. Class B is is mapped with IBatis and I cannot migrate with it to ...

6. Implementing Entity Lifecycle via Hibernate Filters    forum.hibernate.org

Hi Boys, I would like to ask you, how should I correctly implement entity life-cycle using hibernate filters. At this time I have got the following classes and DAOS, which I considered to be right - but they obviously aren't. Here are entities which are used in my system. Code: // AbstractCommontObject ---------------------------------------------- @Entity @FilterDef(name = "softDelete") @Filter(name = "softDelete", condition ...

8. Using Lifecycle and onDelete to implement logical delete    forum.hibernate.org

I'm looking at creating a system where all persistent objects have a cleanupDate field, and to delete an item, you just set the cleanup date to the current date. All persistent objects in my system extend a common class and I thought I could just implement something like this for the onDelete() method in that class (which extends Lifecycle): Code: ...

9. Lifecycle method call.    forum.hibernate.org

Hello, I need to implement a class where the instance need to embed the creation date and the last modification date. Regarding the documentation, the Lifecycle implementation seems to be exactly what i need. So imagine the following class: Code: public class Foo implements Lifecycle { /** * The Class Log. ...





10. Lifecycle update    forum.hibernate.org

11. saveOrUpdate not calling Lifecycle.onUpdate or Lifecycle.onS    forum.hibernate.org

Gavin, Thanks for responding. I actually have read the Javadoc and was expecting the when session.saveOrUpdate is called that either save or update will be called on the passed entity. But this is not what I am seeing in my application. This is working when I just use save or update though. Thanks, Haytham

12. Lifecycle: how to get it work?    forum.hibernate.org

I actually read both - and found interceptor not really suitable for my needs. I would say that: "Optionally, a persistent class might implement the interface Lifecycle which provides some callbacks that allow the persistent object to perform necessary initialization/cleanup after save or load and before deletion or update." means my persistent class will get the opportunity to do some things ...

13. Lifecycle dilemma: FK violation or flush during cascade?!    forum.hibernate.org

Author Message RobJellinghaus Post subject: Lifecycle dilemma: FK violation or flush during cascade?! Posted: Wed Mar 10, 2004 3:58 pm Expert Joined: Thu Jan 08, 2004 6:17 pm Posts: 278 I seem to be unable to use Lifecycle to implement a custom lifecycle for some of my application entities. I am hoping there is an easy pattern that I ...

14. Lifecycle objects being sent to an early grave    forum.hibernate.org

When I have a SQL failure (value to large for column) during a save (or saveOrUpdate), the lifecycle objects are discarded from the Set on the containing object. Briefly, something like this: public class Wart extends Synchonzied { public Wart(Frog frog) { this.host = frog; } Long id = null; String color = null; Frog host = null; ... } public ...

15. Tying my domain objects to Lifecycle    forum.hibernate.org

If my domain objects are using the Lifecycle objects extensively, I'm already creating a strong dependency to Hibernate. Now from my Stateless Session Bean facade, should I create a Transfer Object from my Domain Object ? Note my SLSB is returning the object to a Struts web tier which incidentally will also have to deal with roundtripping from transfer objects to ...

16. lifecycle - caching/retrieving user object    forum.hibernate.org

Hi, When I save my business object (e.g. Employee), I stamp the record with a "last_modified_date" value and a "last_modified_user" reference. (which links to the User class of system users). This allows my reports to say Last modified by wglass 5/4/04. Right now, every time my business logic saves the Employee object, it has to update these two fields. It occurs ...





17. Session mgmt with mixed sql and lifecycle objects    forum.hibernate.org

I have a coarse-grained object, Review, that is configured by the user in a series of steps: 1. Create a Review by defining it's scope (product lines etc) and identity (author, date, etc). 2. Upload XML data files. 3. Set some comparison parameters. 4. Apply a series of rules to each item under review (Bulk). 5. Page through the items which ...

18. Lifecycle.onUpdate() not called from Session.saveOrUpdate()    forum.hibernate.org

I have the problem that Lifecycle.onUpdate() is not called from Session.saveOrUpdate() when the updated object was loaded in the same Session; I didn't notice this before because most of the time I use detached objects. I looked into SessionImpl.saveOrUpdate() and saw that the existence of an EntityEntry causes this behavior. Calling Session.evict() before Session.saveOrUpdate() solved my problem, but it is my ...

20. there is an interface opposed to Lifecycle?    forum.hibernate.org

21. Why lifecycle interface can't work property?    forum.hibernate.org

Senior Joined: Wed Dec 17, 2003 4:24 am Posts: 188 Read the rules before posting! http://www.hibernate.org/ForumMailingli ... AskForHelp 2.1.6 ////////////////////////////////////////////////////////////////////////

22. Can't build sessionfactory in Lifecycle of SUN ONE PE 8.1?    forum.hibernate.org

I will build sessionfactory in Lifecycle of SUN ONE PE 8.1, An error report as : [#|2005-04-19T15:24:05.442+0800|WARNING|sun-appserver-pe8.1|javax.enterprise.system.stream.err|_ThreadID=10;|java.lang.Error: Using the FastClass empty constructor--please report to the cglib-devel mailing list at net.sf.cglib.reflect.FastClass.(FastClass.java:31) at sun.reflect.GeneratedSerializationConstructorAccessor74.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Constructor.java:274) at com.sun.corba.ee.impl.copyobject.newreflect.ClassCopierOrdinaryImpl.createCopy(Unknown Source) at com.sun.corba.ee.impl.copyobject.newreflect.ClassCopierBase.copy(Unknown Source) at com.sun.corba.ee.impl.copyobject.newreflect.ClassCopierOrdinaryImpl$22.copy(Unknown Source) at com.sun.corba.ee.impl.copyobject.newreflect.ClassCopierOrdinaryImpl$ClassFieldCopierUnsafeImpl.copy(Unknown Source) at com.sun.corba.ee.impl.copyobject.newreflect.ClassCopierOrdinaryImpl$ClassFieldCopierUnsafeImpl.copy(Unknown Source) at com.sun.corba.ee.impl.copyobject.newreflect.ClassCopierOrdinaryImpl.doCopy(Unknown Source) at com.sun.corba.ee.impl.copyobject.newreflect.ClassCopierBase.copy(Unknown Source) at com.sun.corba.ee.impl.copyobject.newreflect.ClassCopierOrdinaryImpl$22.copy(Unknown Source) at com.sun.corba.ee.impl.copyobject.newreflect.ClassCopierOrdinaryImpl$ClassFieldCopierUnsafeImpl.copy(Unknown ...

23. 16.3. Cascading lifecycle    forum.hibernate.org

I'm, trying to implement cascade saving in the posted code below. I'm trying to reproduce the examples provided in section 16.3 in Hibernate reference documentation (2.1.7). I get net.sf.hibernate.HibernateException: Batch update row count wrong: 0 while trying... Hibernate version: 2.1.7c Mapping documents:

24. Design: session lifecycle in a GUI application    forum.hibernate.org

How do GUI applications typically manage the session lifecycle? I'm used to using Hibernate in Web applications where the session lifecycle is pretty clear. The GUI application I'm working on opens a session for the first database transaction from a thread and then just holds it open until the application is closed. This model fails when multiple instances of the application ...

25. Session.merge() and Lifecycle    forum.hibernate.org

A simple test indicates that the behavior of Session.merge() is inconsistent when a model object implements the Lifecycle interface. The onLoad(), onSave() methods of Lifecycle are invoked at appropriate times during the Session.merge() method, but the onUpdate() method is never invoked. On the other hand, the Session.saveOrUpdate() method invokes onLoad(), onSave() and onUpdate() correctly. I need this function to update the ...

26. Lifecycle method to update second column based on pkey    forum.hibernate.org

Hello I want to do the following. How can I achieve this implementing Lifecyle on domain object? I insert a transaction record. Based on Id generated for this record, I want to update second column in that record with same id concatenated with some text. How can I achieve this using Lifecycle onSave? Id (Primary key) is sequence generated for this ...

27. Hib Gurus: Can anyone explain CGLib proxy lifecycle/access?    forum.hibernate.org

At the risk of oversimplifying the issue can anybody with a good understanding of the CGLib runtime proxies explain, from a Hibernate users perspective, the: 1) proxy lifecycle. Eg When are they created and returned, where are they stored and when are they replaced by the persistent entities they are proxying for. and 2) proxy access sequence flow - eg. when ...

29. why Lifecycle interface's onLoad has the id as a parameter?    forum.hibernate.org

public class Course implements Lifecycle { private Long id; private String name; private Long duration; public void setId(Long id) { this.id = id; } public Long getId() { return id; } public void ...

30. Struts+Hibernate: Hibernate session lifecycle question    forum.hibernate.org

Hi, thanks for you answer and sorry for late reaction :-) That's a very interesting article - have never come accross to it. If I understand correctly the session for View stays opened until the "real" action comes and does commit and close... The good thing is that probably I don't have to rebuild my solutions as I have two abstract ...

31. The Lifecycle interface and Hibernate 3    forum.hibernate.org

Hi all, my current task at work is to update our e-commerce application DAO layer from H2 to H3. For this task I really appreciated your "Migration Guide" and want to thank you very much for doing so. But I have a problem with the current (old) code that uses the H2 Lifecycle interface in this way (example code): Code: public ...