Hi guys, I was browsing through the EJB 3.0 / JPA specification
recently and I noticed that one of our PersistentEntityDao methods is
named and actually implemented using Hibernate-specific operation:
public <S extends T> S saveOrUpdate(S entity);
Method implementation:
getSession().saveOrUpdate(entity);
return (S) getSession().merge(entity);
This method therefore triggers SAVE_UPDATE and MERGE cascade types
(note that SAVE_UPDATE is Hibernate-specific too). saveOrUpdate()
comes historically from times when DAO Fusion was directly bound to
Hibernate.
To make PersistentEntityDao fully compliant to JPA specification, I
would recommend to break saveOrUpdate() into two methods: persist()
and merge(). Following image depicts the standard JPA entity life
cycle:
http://java.boot.by/scbcd5-guide/images/060100.gif
Second task would be to actually test corresponding JPA cascade types
(PERSIST and MERGE) in core integration tests (we might test other
cascades as well if necessary).
What's your opinion?