Package fr.valtech.many2many.domain

Examples of fr.valtech.many2many.domain.Recipe


        // recette1
        recipeDAO.save(recipe);
        flushSession();
        entityManager.clear();

        Recipe fullRecipe = recipeDAO.getRecipeById(recipe.getId());
        entityManager.clear();

        assertEquals(recipe.getId(), fullRecipe.getId());
        for (RecipeIngredient ri : fullRecipe.getRecipeIngredients()) {
            assertFalse(ri.getPk().getIngredient() instanceof HibernateProxy);
        }
    }
View Full Code Here


    @Test
    public void testGetRecipeByUnknownId() throws Exception {

        Integer unknownId = new Integer(12345);
        Recipe notFoundRecipe = recipeDAO.getRecipeById(unknownId);
        entityManager.clear();

        assertNull(notFoundRecipe);

    }
View Full Code Here

    }

    private Recipe detachRecipe(Recipe r) {

        Recipe detachedRecipe = new Recipe();
        detachedRecipe.setId(r.getId());
        detachedRecipe.setTitle(r.getTitle());

        Iterator<RecipeIngredient> it = r.getRecipeIngredients().iterator();
        while (it.hasNext()) {
            RecipeIngredient ri = it.next();
            Ingredient i = new Ingredient();
            i.setId(ri.getIngredient().getId());
            RecipeIngredient detachedRi = new RecipeIngredient(i,
                    ri.getAmount());
            detachedRecipe.addRecipeIngredient(detachedRi);
        }

        return detachedRecipe;

    }
View Full Code Here

    @Override
    public Recipe getLastRecipe() {
        Query q = getEntityManager().createQuery("select max (id) from Recipe");

        Recipe recipe = null;
        try {
            Integer id = (Integer) q.getSingleResult();
            recipe = this.getRecipeById(id);
        } catch (NoResultException nre) {
            getLogger().info("no result found");
View Full Code Here

                        + "left join fetch pk.ingredient "
                        + "where r.id = :recipeId");

        q.setParameter("recipeId", recipeId);

        Recipe recipe = null;
        try {
            recipe = (Recipe) q.getSingleResult();
        } catch (NoResultException nre) {
            getLogger().info("no result found");
            return null;
View Full Code Here

TOP

Related Classes of fr.valtech.many2many.domain.Recipe

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.