Re: EntityManager EclipseLink problem?
Charles Bedon <[email protected]>
| Newsgroups | gmane.comp.java.netbeans.modules.openide.devel |
|---|---|
| Message-ID | <CA+0gwA0mWtexACK-JV5G=LZSWF9ybfBH-WGD01D8ALXF15qG1w@mail.gmail.com> |
Hello Mark, Could it be somehow related to the caching strategy you're using? Try disabling cache: http://wiki.eclipse.org/EclipseLink/FAQ/How_to_disable_the_shared_cache%3F Kind regards, On 12/7/16, Mark Wade <[email protected]> wrote: > Hello, > > I'm somewhat hesitant to post this as I'm not sure this forum is the > proper place or that I can provide enough information in an appropriate > manner such as to be of any help but I'm going to give it a shot anyway. > > > I used the new entity classes from database wizard to create, among > others, the classes Item and Category. An item has a category and a > category can have many items and NetBeans has generated a > itemsCollection in Category. One of the views on the data is a > BeanTreeView whose root node contains CategoryBeanNodes whose > instanceContent contains a category and whose leaf nodes are > ItemBeanNodes whose instanceContent contains an item. > > > As I edit the items and save the edits I need to update the view > accordingly. Now, especially when moving an item from one category to > another, the first edit/save cycle was fine so I thought all was good > but then somewhere I moved the item to another category, saved, and then > back again and saved and then maybe a third edit/save cycle and my view > was no longer displaying the data properly, either showing the item in > two categories or not moving the item at all. > > > Now, I refresh the view after the transaction is committed and the > entityManager is closed and at that point the database is in the proper > state and to refresh the view I create a named query to get all the > categories but the resultList is not what is in the database. Either the > category's itemCollection doesn't contain the item it should or it > contains an item that should no longer be there. I've come up with a > workaround and ,while it works, it seems pretty ugly to me and I don't > know why I should need to do it. Basically I'm iterating through the > resultList and checking if the categories' itemCollections are in the > state expected and if not correcting them. > > > But why should this be so? Maybe this is of use: > > public class Item implements Serializable { > > ... > > @JoinColumn(name = "category_id", referencedColumnName = "id") > @ManyToOne > private Category categoryId; > > ... > } > > public class Category implements Serializable { > > ... > > @OneToMany(mappedBy = "categoryId") > private Collection<Item> itemCollection; > > ... > > } > > > Thanks for taking the time to look, > > -- Mark > > > > -- Charles Edward Bedón Cortázar http://www.neotropic.co | Network Management, Data Analysis and Free Software | twitter.com/neotropic_co Open Source Network Inventory for the masses! http://kuwaiba.sourceforge.net | Follow Kuwaiba on Twitter<http://twitter.com/kuwaiba> Linux Registered User #386666