It seems you are using Java and Hibernate. This mailing list is about NHibernate.
>> s.beginTransaction().commit(); The transaction should of course be started BEFORE you do any modifications. /Oskar 2011/4/13 spillo17 <[email protected]>: > i > > On 13 Apr, 16:07, spillo17 <[email protected]> wrote: >> When I make an insert in db, I see this error: Illegal attempt to >> associate a collection with two open session , and insert doesn't >> work. >> >> My insert is this: >> >> public void InsertOrder(List<ProductBasket> products, Float total) >> { >> Session s = HibernateUtil.currentSession(); >> for (ProductBasket prodOrd : products) { >> for (Product product : GetAllProducts()) { >> if (prodOrd.getId().equals(product.getId())) { >> OrderProduct orderProd = new >> OrderProduct(prodOrd.getQuantity(), prodOrd.getColor(), >> prodOrd.getSize()); >> orderProd.setOrder(new ShippingOrder(new Date(), >> total, "open")); >> orderProd.setProduct(product); >> s.save(orderProd); >> >> } >> >> } >> } >> s.beginTransaction().commit(); >> } >> >> I don't understand where is the problem. > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
