views:

157

answers:

1

The question is this. I have a number of persisted objects that I'll pull using Hibernate.

But during the application lifetime I'll create a few objects that do not live outside the running time of an app.

They are temporary, for example contain user's choices, and they also hold links to the persistent objects(tables). But as soon as application exited, there's no need in them so temporary objects are destroyed.

How do you think, should those objects be persisted in the same database where normal data is kept?

For example, they may be kept in temporary tables and on exit the data will be erased.

Or they may be created only in memory. Which is better?

+2  A: 

You generally don't persist transient objects, unless there are a lot of them gobbling up memory and/or the objects are accessed only rarely, at which point the memory freed by not having them in memory can be used better.

In my opinion, the basis of every design should be simplicity. As simple as possible while as complex as required. Adding Hibernate to those objects adds complexity and potential for trouble, and if it's not necessary then don't do it.

extraneon