Hi guys,

I'm trying to find if Hibernate supports something like this:

https://wiki.eclipse.org/EclipseLink/DesignDocs/340192

It would be really nice if there was something in the JPA spec about it, but if not I would be glad even if there's a custom Hibernate feature.
Hello,

I'm working on a JPA-enabled project, which is designed to be modular. The core of the project contains some @Entity-ies and the modules add more @Entity-ies, depending on which jar you include in the classpath. My problem occurs when I try to include the promotion module. The promotion module contains the ProductPromotion entity, which has a Set of Product-s, and they are mapped with @ManyToMany:

@Entity
public class ProductPromotion {

@ManyToMany(fetch = FetchType.LAZY, targetEntity = Product.class, cascade = { CascadeType.ALL })
@JoinTable(name = "productpromotion_product", joinColumns = @JoinColumn(name = "promotion_pk"), inverseJoinColumns = @JoinColumn(name = "product_pk"))
private Collection<Product> products;
}

I only map ProductPromotion, because Product is in the core, and it doesn't know if the promotion module will be enabled, so ProductPromotion is not in its classpath. This way the ProductPromotion becomes the owning side of the @ManyToMany, and when I try to delete a Product from the db it fails with constraint violation exception that productpromotion_product table has a foreign key pointing to this product so it cannot be deleted. I was hoping that the @ManyToMany annotation has the orphanRemoval attribute but it seems like it is not there smilie .. Can you please tell me why is it not there? What I would like to do is when deleting the product to have the records from productpromotion_product associated with that product automatically deleted. Or at least make hibernate not throw the exception. Is that possible?
Hi JGF1,

the subversion repository is here:

https://junitbook.svn.sourceforge.net/svnroot/junitbook/trunk/junitbook2/

Cheers, Petar.
Ooopss... good catch smilie. It's already taken care of.
Hi shetc,

the mock objects chapter (chapter 7) is already finished and will be online in the MEAP some time this or next week.

Thanks, Petar.
It is already there.

Cheers, Petar.
Hi Ted,

thanks for the feedback smilie. None of me and Felipe is a native English speaker, and there might be even more of these typos, wordos... Particularly this Appendix was written by me, so the shame is on me smilie.

Anyway, I do believe that these kind of feedback is valuable, despite the fact that the chapters in the MEAP are straight from the author, and have not passed any editing.

I will personally take care of making the Appendix typo/wordo
Hi Carlos,

quick eye smilie

We decided to swap places of chapter 6 and chapter 7. It seems more natural to explain Stubs first and then Mocks.

Thanks for the notice.
Hi Scott,

we are planing to describe the new assertThat and assumeThat features of JUnit.. We are planning to cover the core matchers in org.hamcrest.CoreMatchers and org.junit.matchers.JUnitMatchers packages that come with JUnit 4.5. There will be probably not enough space to describe all the matchers from the hamcrestall.jar.

Cheers, Petar.
Hi everybody,

Welcome to the JUnit in Action 2nd Edition (JIA2) forum. Please use this forum to post your comments about the JIA2 code or text.

Petar
Hi Aldian,

as I see the situation you currently have two options - the first one is to simulate the JNDI lookup with Mock objects, and the second one is to write in-container tests with Cactus. We cover Mock objects in the whole second part of the book, and I am currently writing chapter 14 about in-container testing with Cactus (I have included a section on how to test EJBs). You are free to choose whichever method you want, and I think our book will cover it good.

Cheers, Petar.