Note that there are some explanatory texts on larger screens.

plurals
  1. POTesting Hibernate DAO, without building the universe around it
    primarykey
    data
    text
    <p>We have an application built using spring/Hibernate/MySQL, now we want to test the DAO layer, but here are a few shortcomings we face.</p> <p>Consider the use case of multiple objects connected to one another, eg: Book has Pages.</p> <ul> <li>The Page object cannot exist without the Book as book_id is mandatory FK in Page.</li> <li>For testing a Page I have to create a Book.</li> </ul> <p>This simple usecase is easy to manage, but if you start building a Library, till you don't create the whole universe surrounding the Book and Page, you cannot test it! </p> <p>So to test Page; </p> <ul> <li>Create Library</li> <li>Create Section</li> <li>Create Genre</li> <li>Create Author</li> <li>Create Book</li> <li>Create Page </li> <li>Now test Page.</li> </ul> <p>Is there an easy way to by pass this "universe creation" and just test the page object in isolation. I also want to be able to test HQLs related to Page. eg: </p> <pre><code>SELECT new com.test.BookPage (book.id, page.name) FROM Book book, Page page. </code></pre> <p>JUnit is supposed to run in isolation, so I have to write the code to build all the supporting objects in the test case to create the Page. Any tips on how to accelerate the process. </p> <p><strong>Edit:</strong> Spring follows the philosophy of transaction roll-back after the tests have been run, thereyby reverting all changes. Schema changes are expected as we develop further, I want to be able to test it against the production db (backup!) on a regular basis.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload