[BAEL-3936] Fixed the name of menu table

This commit is contained in:
Kostas Karavitis 2020-04-08 18:44:32 +03:00
parent 6677cf74d1
commit 74e02b2216
2 changed files with 6 additions and 3 deletions

View File

@ -1,5 +1,7 @@
package com.baeldung.jpa.unrelated.entities; package com.baeldung.jpa.unrelated.entities;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction; import org.hibernate.annotations.NotFoundAction;
@ -8,7 +10,7 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
@Entity @Entity
@Table(name = "cocktails") @Table(name = "menu")
public class Cocktail { public class Cocktail {
@Id @Id
@Column(name = "cocktail_name") @Column(name = "cocktail_name")
@ -22,7 +24,7 @@ public class Cocktail {
@OneToOne @OneToOne
@NotFound(action = NotFoundAction.IGNORE) @NotFound(action = NotFoundAction.IGNORE)
@JoinColumn(name = "cocktail_name", @JoinColumn(name = "cocktail_name",
referencedColumnName = "cocktail", referencedColumnName = "cocktail",
insertable = false, updatable = false, insertable = false, updatable = false,
foreignKey = @javax.persistence foreignKey = @javax.persistence
@ -30,7 +32,7 @@ public class Cocktail {
) )
private Recipe recipe; private Recipe recipe;
@OneToMany @OneToMany(fetch = FetchType.LAZY)
@NotFound(action = NotFoundAction.IGNORE) @NotFound(action = NotFoundAction.IGNORE)
@JoinColumn( @JoinColumn(
name = "cocktail", name = "cocktail",

View File

@ -38,6 +38,7 @@ public class UnrelatedEntitiesUnitTest {
entityManager.close(); entityManager.close();
} }
@Test @Test
public void whenQueryingForCocktailThatHasRecipe_thenTheExpectedCocktailReturned() { public void whenQueryingForCocktailThatHasRecipe_thenTheExpectedCocktailReturned() {
// JPA // JPA