Package org.hibernate.examples.mapping.compositeId.manytoone

Examples of org.hibernate.examples.mapping.compositeId.manytoone.OrderDetail


        Product product = new Product();
        product.setName("monitor");
        em.persist(product);

        OrderDetail detail = new OrderDetail(order, product);
        order.getOrderDetails().add(detail);
        product.getOrderDetails().add(detail);

        em.persist(detail);
        em.flush();
        em.clear();

        OrderDetail loaded = em.find(OrderDetail.class, detail.getId());
        assertThat(loaded).isNotNull();
        assertThat(loaded.getId().getOrder()).isNotNull();
        assertThat(loaded.getId().getProduct()).isNotNull();

        loaded.setQuantity(12);
        em.persist(loaded);
        em.flush();
        em.clear();

        loaded = em.find(OrderDetail.class, detail.getId());

        assertThat(loaded).isNotNull();
        assertThat(loaded.getId().getOrder()).isNotNull();
        assertThat(loaded.getId().getProduct()).isNotNull();

        em.remove(loaded);
        em.flush();
        em.clear();
    }
View Full Code Here

TOP

Related Classes of org.hibernate.examples.mapping.compositeId.manytoone.OrderDetail

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.