Sunday, August 28, 2016

Hibernate JPA OneToOne association with common primary key

Imagine, that you need to create a movies database, which stores a movie details and a details on a book, on which the movie was done. A book details are optional, since a movie may be not based on a book. A movie details are: title, release date, country, genre, language. A book details are: title, author, country, language.

You might define a table MOVIES that contains details for both a movie and a book. If a movie is not done on a book, the book-related columns will be null. For relational database such model means a waste of space, since a data column takes space according to its data type, no matter if data is null.

Monday, August 15, 2016

Updating Hibernate JPA entity collection

A detached entity (a.k.a. a detached object) is an object that has the same ID as an entity in the persistence storage but that is no longer a part of a persistence context (the scope of an EntityManager session). The two most common causes for this are:
• The transaction, in which the object was created, is closed.
• The object was received from outside as a part of a form submission, a remote protocol such as REST etc.

Tuesday, August 2, 2016

Using Guice for Play tests

The earlier post Unit testing and mocking with PowerMock in Play explains, how to define unit tests with the class WithApplication and Helpers.fakeApplication(). Such test is executed with the default injection binding, which is defined in a Play module. The default binding may be not appropriate for a particular test.

About the author

My Photo
I trust only simple code and believe that code should be handsome. This is not a matter of technology, but professional approach, consolidated after years of software development. I enjoy to cause things working and feel very happy, when I manage to solve a problem.
Back to Top