facebook

DAO – Container managed Transaction? [Closed]

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #199669 Reply

    I am implementing a DAO right now. Because myEclipse currently lacks any support for DAO, I would like to know something about the transaction management. The DAO will be limited to be used by a single Session Bean implementation only. The DAO will manage a properties like table storing string values for diffrent languages and items. Therefore I am interested in how a DAO is covered by transactions of the session bean.

    The DAO will look up for an connection and execute some SQL statements. So the question is, what happends if the Session Bean calls the DAO? Is any transaction the Session Bean belongs to, automatically expanded within the DAO? Or do I add some JTA code?

    By the way, I am currently using JBoss+Tomcat+MySQL.

    #199672 Reply

    Scott Anderson
    Participant

    Martin,

    The DAO will look up for an connection and execute some SQL statements. So the question is, what happends if the Session Bean calls the DAO? Is any transaction the Session Bean belongs to, automatically expanded within the DAO? Or do I add some JTA code?

    It’s automatic. All SQL calls made by the DAO will become part of the J2EE container’s current transaction automatically, provided there is one. The easiest way to ensure that a transaction exists is by setting your EJB deployment descriptor so that transactions are container managed and required for all your public methods.

    You can learn much more about how all of this works by referencing the appropriate EJB specification document for your server’s specification level.

    –Scott
    MyEclipse Support

    #199676 Reply

    @scott wrote:

    It’s automatic. All SQL calls made by the DAO will become part of the J2EE container’s current transaction automatically, provided there is one.

    Ok thanks. I was a bit afraid. I read an article about DAO implementation at IBM. The article stated out, there are two ways for transaction handling, use JTA or SQL. Seams I missinterpreted them. They are only referring to web-components like servlets and only the programatic transactional aproach is demonstrated. So it seams that I mixed it up a bit. 🙂

    (article link: http://www-106.ibm.com/developerworks/java/library/j-dao/)

    @scott wrote:

    You can learn much more about how all of this works by referencing the appropriate EJB specification document for your server’s specification level.

    I read some books about it and got some curses on my university. But the fun is, noone stated out (as far as I remember), that a database source is using the containers transaction level, when the bean optains it by looking up for it. I also reread the transaction chapter of the J2EE book of O’Reilly. No mention of it. Thats why I’ve asked. 😉

    It’s also a bit wired though. Doing an lookup request and geting a ready to use setted up database source. I am simply not used to such easyness. 😉

    Thanks for your help Scott!

    Martin

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: DAO – Container managed Transaction? [Closed]

You must be logged in to post in the forum log in