It depends whether your working with detached or manages entities. Are you using OSIV?

Sven

On 06/14/2013 12:22 AM, Boris Brinza wrote:
Hello,
ok, i understand what my problem was,
I've update my code to use detachable model, quite easy refactorting.

But it only postponed my problem to model onDetach, if i understand it right. In pdf, "If we don't want to loose these changes we must explicitly persist the entity before the detaching phase occurs." So same problem with update of JPA enbtity. Insert is ok, just call persist(), but update?



On 06/13/2013 02:52 PM, Sven Meier wrote:
Please read "9.6 Detachable models" of the Wicket Free Guide and come back with your questions.

Sven

On 06/13/2013 01:20 PM, Boris Brinza wrote:
Hello to all,
I have some fundamental issues with integration of jpa into wicket.
I develop web application using wicket 6 and JPA (eclipselink). Maybe next question is more JPA oriented, but nevertheless:

Lets say i have
class BaseDetailPage<T extens BaseDO> extends WebPage {
    protected <T> dbEntity;

}

where dbEntity is instance of jpa persisted object.
BaseDetail page contains form for editing db entity using CompoundPropertyModel.

After i open detail page, entity is read from DB and page is displayed (if edit button is pressed) or i create new instance of object (if add button is pressed).

After submit, if i want to add new record, everything is clear, i call beginTX(), entityManager.persist(dbEntity), commitTX().

But what about updating existing record?

Every example for JPA shows some basic code like this:
beginTX()
dbObject.setXXX();
dbObject.setYYY();
commitTX()


But how to integrate this into wicket form using compound property model? There is no such code for setting properties of db object, and jpa does not have anything like entityManager.update().

Now i use hack (by my opinion it';s a hack)

beginTX()
entityManaget.detach(dbObject);
entityManager.merge(dbObject)
commitTX()

but i am not sure, if it's right solution (or i'm almost sure it's not right attitude)

Is there any tutorial how to integrate these frameworks, or some simple opensource project to check how it's solved?

Thanks for any advice,
Boris




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to