Thank you for your nice and informative reply!
To clearify a bit, even though I think you understood me, it's always nice to be clear and I feel I could improve on my previous post. :-)
The tree structure I'm talking about uses aggregation, not inheritence. Which means that it's a tree structure of entity instances.
So, let's not make the fetch type eagar for children. That's my instinct if getChildren is not called often. Thoughts?
Then I'll have to do things inside a transaction. Which might be a problem.
My original plan was to retrieve the correct TreeNode entity and store it as a session object. Then I'll show a web page with some information about the TreeNode. Next the user performs various actions on the object instance which is temporarly stored in the session. When the user has made all the modifications (s)he wants the TreeNode is updated in the database. Between retrieval of the TreeNode and update there are several calls between
JSP's and
Servlets.
As you can see using transactions isn't a possibility with the above approach. Is the above approach bad? Would it be better to use for example a stateful session bean?
Gavin King (or was it Christian Bauer?) gets all upset when people talk about reading from a database without being in the scope of a transaction. You always need a transaction, don't you?
If I'm only reading. Why would I need to be inside a transaction then? I'm pretty new to databases but I asked my collegues and they didn't know a reason for being in a transaction while only reading either. I'm all eyes and would very much like to know.
What inheritance type mapping are you using? Is this a concern?
I don't think it's a concern as this structure isn't using inheritance yet. In our real world scenario some TreeNode's will have extended information, let's call them HaikuTreeNode's. They will hold methods for interacting with their Haiku information as well. But I don't think it's relevant.