How do I keep entities (or their associations) attached to the current persistence context across multiple requests (using Wicket & JPA)?

后端 未结 2 2171
情话喂你
情话喂你 2021-02-20 07:15

I am working on a Wicket-based web app on Java EE.

I am trying to find a way to ensure that any entities used as model objects are always attached to the current EntityM

2条回答
  •  佛祖请我去吃肉
    2021-02-20 07:58

    Seems to be kindof an old post..

    I hope it will help some others anyway:

    First: Your LDM is a bit useless, because the entity property is not transient. Therefore your entity gets serialised to your session store and thats not the meaning of an LDM. It's supposed to minimize the serialization size of any modeldata.

    Second: Your problem isn't a real problem, cause what you need, is what you already have: You want to prepare an Entity over several pages to be finally stored in your database (some wizard or so..). Now, that your LDM is fully serialized to your session store between the requests of the client, your entity and its edited data survives multiple requests, no need for any merging. As soon, as your wizard is finished, you simply persist the hole entity. Before the entity is in its final state, it doesn't make sense to persist anything (though it survives over requests in your session store).

    You don't even need the LDM for this kind of funcionality..

    Simply give the entity as parameter to the next page, where the user may complete its data.

    Hope you solved this problem already..

提交回复
热议问题