[BAEL-3936] Fixed format to use 2-space indenting for line continuations.
This commit is contained in:
parent
717b0e1711
commit
6a08fca7aa
@ -56,15 +56,16 @@ public class MultipleRecipe {
|
|||||||
if (o == null || getClass() != o.getClass())
|
if (o == null || getClass() != o.getClass())
|
||||||
return false;
|
return false;
|
||||||
MultipleRecipe that = (MultipleRecipe) o;
|
MultipleRecipe that = (MultipleRecipe) o;
|
||||||
|
|
||||||
return Objects.equals(id, that.id) &&
|
return Objects.equals(id, that.id) &&
|
||||||
Objects.equals(cocktail, that.cocktail) &&
|
Objects.equals(cocktail, that.cocktail) &&
|
||||||
Objects.equals(instructions, that.instructions) &&
|
Objects.equals(instructions, that.instructions) &&
|
||||||
Objects.equals(baseIngredient, that.baseIngredient);
|
Objects.equals(baseIngredient, that.baseIngredient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id, cocktail,
|
return Objects.hash(id, cocktail,
|
||||||
instructions, baseIngredient);
|
instructions, baseIngredient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,11 +34,13 @@ public class Recipe {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o)
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
Recipe recipe = (Recipe) o;
|
Recipe recipe = (Recipe) o;
|
||||||
return Objects.equals(cocktail, recipe.cocktail) &&
|
return Objects.equals(cocktail, recipe.cocktail)
|
||||||
Objects.equals(instructions, recipe.instructions);
|
&& Objects.equals(instructions, recipe.instructions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,9 +27,9 @@ public class UnrelatedEntitiesUnitTest {
|
|||||||
entityManager.persist(ginTonic);
|
entityManager.persist(ginTonic);
|
||||||
entityManager.persist(new Recipe(mojito.getName(), "Some instructions"));
|
entityManager.persist(new Recipe(mojito.getName(), "Some instructions"));
|
||||||
entityManager.persist(new MultipleRecipe(1L, mojito.getName(),
|
entityManager.persist(new MultipleRecipe(1L, mojito.getName(),
|
||||||
"some instructions", mojito.getCategory()));
|
"some instructions", mojito.getCategory()));
|
||||||
entityManager.persist(new MultipleRecipe(2L, mojito.getName(),
|
entityManager.persist(new MultipleRecipe(2L, mojito.getName(),
|
||||||
"some other instructions", mojito.getCategory()));
|
"some other instructions", mojito.getCategory()));
|
||||||
entityManager.getTransaction().commit();
|
entityManager.getTransaction().commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,56 +43,56 @@ public class UnrelatedEntitiesUnitTest {
|
|||||||
public void givenCocktailsWithRecipe_whenQuerying_thenTheExpectedCocktailsReturned() {
|
public void givenCocktailsWithRecipe_whenQuerying_thenTheExpectedCocktailsReturned() {
|
||||||
// JPA
|
// JPA
|
||||||
Cocktail cocktail = entityManager.createQuery("select c "
|
Cocktail cocktail = entityManager.createQuery("select c "
|
||||||
+ "from Cocktail c join c.recipe", Cocktail.class)
|
+ "from Cocktail c join c.recipe", Cocktail.class)
|
||||||
.getSingleResult();
|
.getSingleResult();
|
||||||
verifyResult(mojito, cocktail);
|
verifyResult(mojito, cocktail);
|
||||||
|
|
||||||
cocktail = entityManager.createQuery("select c "
|
cocktail = entityManager.createQuery("select c "
|
||||||
+ "from Cocktail c join Recipe r "
|
+ "from Cocktail c join Recipe r "
|
||||||
+ "on c.name = r.cocktail", Cocktail.class)
|
+ "on c.name = r.cocktail", Cocktail.class)
|
||||||
.getSingleResult();
|
.getSingleResult();
|
||||||
verifyResult(mojito, cocktail);
|
verifyResult(mojito, cocktail);
|
||||||
|
|
||||||
// QueryDSL
|
// QueryDSL
|
||||||
cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
|
cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
|
||||||
.join(QCocktail.cocktail.recipe)
|
.join(QCocktail.cocktail.recipe)
|
||||||
.fetchOne();
|
.fetchOne();
|
||||||
verifyResult(mojito, cocktail);
|
verifyResult(mojito, cocktail);
|
||||||
|
|
||||||
cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
|
cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
|
||||||
.join(QRecipe.recipe)
|
.join(QRecipe.recipe)
|
||||||
.on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail))
|
.on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail))
|
||||||
.fetchOne();
|
.fetchOne();
|
||||||
verifyResult(mojito, cocktail);
|
verifyResult(mojito, cocktail);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenCocktailsWithoutRecipe_whenQuerying_thenTheExpectedCocktailsReturned() {
|
public void givenCocktailsWithoutRecipe_whenQuerying_thenTheExpectedCocktailsReturned() {
|
||||||
Cocktail cocktail = entityManager.createQuery("select c "
|
Cocktail cocktail = entityManager.createQuery("select c "
|
||||||
+ "from Cocktail c left join c.recipe r "
|
+ "from Cocktail c left join c.recipe r "
|
||||||
+ "where r is null", Cocktail.class)
|
+ "where r is null", Cocktail.class)
|
||||||
.getSingleResult();
|
.getSingleResult();
|
||||||
verifyResult(ginTonic, cocktail);
|
verifyResult(ginTonic, cocktail);
|
||||||
|
|
||||||
cocktail = entityManager.createQuery("select c "
|
cocktail = entityManager.createQuery("select c "
|
||||||
+ "from Cocktail c left join Recipe r "
|
+ "from Cocktail c left join Recipe r "
|
||||||
+ "on c.name = r.cocktail "
|
+ "on c.name = r.cocktail "
|
||||||
+ "where r is null", Cocktail.class)
|
+ "where r is null", Cocktail.class)
|
||||||
.getSingleResult();
|
.getSingleResult();
|
||||||
verifyResult(ginTonic, cocktail);
|
verifyResult(ginTonic, cocktail);
|
||||||
|
|
||||||
QRecipe recipe = new QRecipe("alias");
|
QRecipe recipe = new QRecipe("alias");
|
||||||
cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
|
cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
|
||||||
.leftJoin(QCocktail.cocktail.recipe, recipe)
|
.leftJoin(QCocktail.cocktail.recipe, recipe)
|
||||||
.where(recipe.isNull())
|
.where(recipe.isNull())
|
||||||
.fetchOne();
|
.fetchOne();
|
||||||
verifyResult(ginTonic, cocktail);
|
verifyResult(ginTonic, cocktail);
|
||||||
|
|
||||||
cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
|
cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
|
||||||
.leftJoin(QRecipe.recipe)
|
.leftJoin(QRecipe.recipe)
|
||||||
.on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail))
|
.on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail))
|
||||||
.where(QRecipe.recipe.isNull())
|
.where(QRecipe.recipe.isNull())
|
||||||
.fetchOne();
|
.fetchOne();
|
||||||
verifyResult(ginTonic, cocktail);
|
verifyResult(ginTonic, cocktail);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,26 +100,26 @@ public class UnrelatedEntitiesUnitTest {
|
|||||||
public void givenCocktailsWithMultipleRecipes_whenQuerying_thenTheExpectedCocktailsReturned() {
|
public void givenCocktailsWithMultipleRecipes_whenQuerying_thenTheExpectedCocktailsReturned() {
|
||||||
// JPQL
|
// JPQL
|
||||||
Cocktail cocktail = entityManager.createQuery("select c "
|
Cocktail cocktail = entityManager.createQuery("select c "
|
||||||
+ "from Cocktail c join c.recipeList", Cocktail.class)
|
+ "from Cocktail c join c.recipeList", Cocktail.class)
|
||||||
.getSingleResult();
|
.getSingleResult();
|
||||||
verifyResult(mojito, cocktail);
|
verifyResult(mojito, cocktail);
|
||||||
|
|
||||||
cocktail = entityManager.createQuery("select c "
|
cocktail = entityManager.createQuery("select c "
|
||||||
+ "from Cocktail c join MultipleRecipe mr "
|
+ "from Cocktail c join MultipleRecipe mr "
|
||||||
+ "on mr.cocktail = c.name", Cocktail.class)
|
+ "on mr.cocktail = c.name", Cocktail.class)
|
||||||
.getSingleResult();
|
.getSingleResult();
|
||||||
verifyResult(mojito, cocktail);
|
verifyResult(mojito, cocktail);
|
||||||
|
|
||||||
// QueryDSL
|
// QueryDSL
|
||||||
cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
|
cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
|
||||||
.join(QCocktail.cocktail.recipeList)
|
.join(QCocktail.cocktail.recipeList)
|
||||||
.fetchOne();
|
.fetchOne();
|
||||||
verifyResult(mojito, cocktail);
|
verifyResult(mojito, cocktail);
|
||||||
|
|
||||||
cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
|
cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
|
||||||
.join(QMultipleRecipe.multipleRecipe)
|
.join(QMultipleRecipe.multipleRecipe)
|
||||||
.on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail))
|
.on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail))
|
||||||
.fetchOne();
|
.fetchOne();
|
||||||
verifyResult(mojito, cocktail);
|
verifyResult(mojito, cocktail);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,31 +127,31 @@ public class UnrelatedEntitiesUnitTest {
|
|||||||
public void givenCocktailsWithoutMultipleRecipes_whenQuerying_thenTheExpectedCocktailsReturned() {
|
public void givenCocktailsWithoutMultipleRecipes_whenQuerying_thenTheExpectedCocktailsReturned() {
|
||||||
// JPQL
|
// JPQL
|
||||||
Cocktail cocktail = entityManager.createQuery("select c "
|
Cocktail cocktail = entityManager.createQuery("select c "
|
||||||
+ "from Cocktail c left join c.recipeList r "
|
+ "from Cocktail c left join c.recipeList r "
|
||||||
+ "where r is null", Cocktail.class)
|
+ "where r is null", Cocktail.class)
|
||||||
.getSingleResult();
|
.getSingleResult();
|
||||||
verifyResult(ginTonic, cocktail);
|
verifyResult(ginTonic, cocktail);
|
||||||
|
|
||||||
cocktail = entityManager.createQuery("select c "
|
cocktail = entityManager.createQuery("select c "
|
||||||
+ "from Cocktail c left join MultipleRecipe r "
|
+ "from Cocktail c left join MultipleRecipe r "
|
||||||
+ "on c.name = r.cocktail "
|
+ "on c.name = r.cocktail "
|
||||||
+ "where r is null", Cocktail.class)
|
+ "where r is null", Cocktail.class)
|
||||||
.getSingleResult();
|
.getSingleResult();
|
||||||
verifyResult(ginTonic, cocktail);
|
verifyResult(ginTonic, cocktail);
|
||||||
|
|
||||||
// QueryDSL
|
// QueryDSL
|
||||||
QMultipleRecipe multipleRecipe = new QMultipleRecipe("alias");
|
QMultipleRecipe multipleRecipe = new QMultipleRecipe("alias");
|
||||||
cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
|
cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
|
||||||
.leftJoin(QCocktail.cocktail.recipeList, multipleRecipe)
|
.leftJoin(QCocktail.cocktail.recipeList, multipleRecipe)
|
||||||
.where(multipleRecipe.isNull())
|
.where(multipleRecipe.isNull())
|
||||||
.fetchOne();
|
.fetchOne();
|
||||||
verifyResult(ginTonic, cocktail);
|
verifyResult(ginTonic, cocktail);
|
||||||
|
|
||||||
cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
|
cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
|
||||||
.leftJoin(QMultipleRecipe.multipleRecipe)
|
.leftJoin(QMultipleRecipe.multipleRecipe)
|
||||||
.on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail))
|
.on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail))
|
||||||
.where(QMultipleRecipe.multipleRecipe.isNull())
|
.where(QMultipleRecipe.multipleRecipe.isNull())
|
||||||
.fetchOne();
|
.fetchOne();
|
||||||
verifyResult(ginTonic, cocktail);
|
verifyResult(ginTonic, cocktail);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,20 +164,21 @@ public class UnrelatedEntitiesUnitTest {
|
|||||||
|
|
||||||
// JPQL
|
// JPQL
|
||||||
List<MultipleRecipe> recipes = entityManager.createQuery("select distinct r "
|
List<MultipleRecipe> recipes = entityManager.createQuery("select distinct r "
|
||||||
+ "from MultipleRecipe r "
|
+ "from MultipleRecipe r "
|
||||||
+ "join Cocktail c "
|
+ "join Cocktail c "
|
||||||
+ "on r.baseIngredient = c.category",
|
+ "on r.baseIngredient = c.category",
|
||||||
MultipleRecipe.class)
|
MultipleRecipe.class).getResultList();
|
||||||
.getResultList();
|
|
||||||
verifyResult.accept(recipes);
|
verifyResult.accept(recipes);
|
||||||
|
|
||||||
// QueryDSL
|
// QueryDSL
|
||||||
QCocktail cocktail = QCocktail.cocktail;
|
QCocktail cocktail = QCocktail.cocktail;
|
||||||
QMultipleRecipe multipleRecipe = QMultipleRecipe.multipleRecipe;
|
QMultipleRecipe multipleRecipe = QMultipleRecipe.multipleRecipe;
|
||||||
recipes = new JPAQuery<MultipleRecipe>(entityManager).from(multipleRecipe)
|
recipes = new JPAQuery<MultipleRecipe>(entityManager).from(multipleRecipe)
|
||||||
.join(cocktail)
|
.join(cocktail)
|
||||||
.on(multipleRecipe.baseIngredient.eq(cocktail.category))
|
.on(multipleRecipe.baseIngredient.eq(cocktail.category))
|
||||||
.fetch();
|
.fetch();
|
||||||
|
|
||||||
verifyResult.accept(recipes);
|
verifyResult.accept(recipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user