OverviewWith the Hibernate extension you are able to persist a BasicEventList with Hibernate 5.0.x directly. The following description assumes a basic knowledge of Hibernate and how to persist and map a normal java collection. These are the required steps to persist an EventList with Hibernate: List property declaration in entity classEnsure you have an appropriate property declaration for your EventList in your mapped entity class. For example, consider a simple class The class would look like: public class User { Notice the declaration of the field To access the list, Hibernate uses the JavaBeans conventions for properties as default. So you should provide appropriate getter- and setter-methods for your list property as demonstrated above. Alternatively, you could configure Hibernate to use direct field access. In this case, the getter/setter methods are not required. Hibernate mapping for EventListsBasically, an EventList is mapped like a normal List with one exception: ... You have to specify the custom Hibernate type EventList usageYou can use the mapped EventList like any other BasicEventList in
your code. Just keep in mind, although the list behaves like a
BasicEventList, its concrete runtime type will be Advanced usageEventLists loaded with Hibernate will always end up having their own lock and publisher. Most of the time this is no problem, because these lists will be the root of list transformations usually. But sometimes, for example when using CollectionLists or CompositeLists, this could be an issue. Therefore you can customize the EventList creation by
Using list categoriesA list category is a User-defined String that will be associated with a dedicated ReadWriteLock and ListEventPublisher. By specifying a list category for an EventListType, all EventLists created by this type will use the same ReadWriteLock and ListEventPublisher associated with the list category. You can even specify which lock and publisher to use for a dedicated list category. Currently, you have to programmatically set the desired list category on your EventListType by subclassing: /** Custom EventListType using a list category. */ Or: /** Custom EventListType using a list category with specified lock and publisher. */ With Hibernate >= 3.2.4, which includes a fix for Hibernate bug HHH-2336, you are able to configure the list category as a parameter of the collection type in the Hibernate mapping file, so you don't have to subclass EventListType. Here is an example: ... Using a custom EventListFactoryIf list categories don't fit your needs, you can provide your own factory for EventList creation. First implement this simple interface: package ca.odell.glazedlists.hibernate; Then subclass EventListType to set the new ListFactory. public class MyEventListType extends EventListType { Instead of using |
Documentation >