I used to use Hibernate almost all my life. Now I'm trying JPA2 with
EclipseLink, but, I don't know how to write a GenericDao.
I simply don't know how to write a saveOrUpdate like method.
my current code are just like this:
@Transactional
> public B save(B bean) {
> if (bean == null || bean.getId() == null) {
> persist(bean);
> } else {
> bean = update(bean);
> }
> return bean;
> }
>
> protected final B update(B bean) {
> bean = em().merge(bean);
> em().flush();
> return bean;
> }
>
>
It almost work. The only problem is that it dont update the @Version of the
entities.
Whats wrong?
PS: em() return basically my injected Provider<EntityManager>.get().
Thanks in advance.
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-guice/-/2ArinVntNDEJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.