Package org.baeldung.persistence.model

Examples of org.baeldung.persistence.model.Foo


        //
    }

    @Test
    public final void whenEntityIsCreated_thenNoExceptions() {
        service.create(new Foo(randomAlphabetic(6)));
    }
View Full Code Here


        service.create(new Foo(randomAlphabetic(6)));
    }

    @Test(expected = DataIntegrityViolationException.class)
    public final void whenInvalidEntityIsCreated_thenDataException() {
        service.create(new Foo());
    }
View Full Code Here

        service.create(new Foo());
    }

    @Test(expected = DataIntegrityViolationException.class)
    public final void whenEntityWithLongNameIsCreated_thenDataException() {
        service.create(new Foo(randomAlphabetic(2048)));
    }
View Full Code Here

        service.create(new Foo(randomAlphabetic(2048)));
    }

    @Test(expected = InvalidDataAccessApiUsageException.class)
    public final void whenSameEntityIsCreatedTwice_thenDataException() {
        final Foo entity = new Foo(randomAlphabetic(8));
        service.create(entity);
        service.create(entity);
    }
View Full Code Here

        service.create(entity);
    }

    @Test(expected = DataAccessException.class)
    public final void temp_whenInvalidEntityIsCreated_thenDataException() {
        service.create(new Foo(randomAlphabetic(2048)));
    }
View Full Code Here

    @Before
    public final void before() {
        final int minimalNumberOfEntities = 25;
        if (fooService.findAll().size() <= minimalNumberOfEntities) {
            for (int i = 0; i < minimalNumberOfEntities; i++) {
                fooService.create(new Foo(randomAlphabetic(6)));
            }
        }

        session = sessionFactory.openSession();
    }
View Full Code Here

        try {
            tx.begin();
            for (int i = 156; i < 160; i++) {
                final Bar bar = new Bar();
                bar.setName("Bar_" + i);
                final Foo foo = new Foo("Foo_" + (i + 120));
                foo.setBar(bar);
                session.save(foo);
                final Foo foo2 = new Foo(null);
                if (i % 2 == 0)
                    foo2.setName("LuckyFoo" + (i + 120));
                foo2.setBar(bar);
                session.save(foo2);
                bar.getFooSet().add(foo);
                bar.getFooSet().add(foo2);
                session.merge(bar);
            }
View Full Code Here

        session = sessionFactory.openSession();
        tx = session.getTransaction();
        final List<Foo> fooList = Lists.newArrayList();
        for (int i = 35; i < 46; i++) {

            final Foo foo = new Foo();
            foo.setName("Foo_" + (i + 120));
            final Bar bar = new Bar("bar_" + i);
            bar.getFooSet().add(foo);
            foo.setBar(bar);
            fooList.add(foo);

        }
        try {
            tx.begin();
            for (final Foo foo : fooList) {

                session.save(foo.getBar());
                session.save(foo);
            }
            tx.commit();
            session.flush();
        } catch (final HibernateException he) {
View Full Code Here

    // tests

    @Test(expected = DataIntegrityViolationException.class)
    public final void whenEntityWithLongNameIsCreated_thenDataException() {
        fooService.create(new Foo(randomAlphabetic(2048)));
    }
View Full Code Here

    // tests

    @Test(expected = DataIntegrityViolationException.class)
    public void whenInvalidEntityIsCreated_thenDataException() {
        fooService.create(new Foo());
    }
View Full Code Here

TOP

Related Classes of org.baeldung.persistence.model.Foo

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.