I have a question regarding DAO. It seems to me that they work very well in an EJB context if you are using and RDBMS as databases and EJB Containers have a similar understanding of what a TX is. At the end of the TX the db changes are either applied or rolled back. The EJB code doesn't need to worry about this. What happens if the concrete DAO classes are backing onto say LDAP, a XMI db, a remote legacy server or some unusual persistence scheme?

In the case of an exception in the EJB would have to know to manually rollback and persistence operations that may have been applied to the datastore since the TX started. Has anyone given this an thought?

My initial thoughts are that you would have to build this logic into the DAO classes themselves.

Any ideas greatly appreciated.