Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [dali-dev] JPA model listeners

Dimov, Stefan wrote:
JPA model listeners

        I have a question regarding listeners in the JPA model - I want to add one or more listeners to the JavaPersistentType objects, so they be able to "catch" any change in the model like changing the underlying entity name, changing an entity attribute name, removing of an existing, adding of a new attribute. I've had a glance on the API, but I'm not sure what to use. For example: what does addCollectionChangeListener(...) do? Which methods I have to use? It would be nice, if I could see a source code snippet! Can anybody give me some helpful info?

There are a number of different types of listeners you can add to JavaPersistentType (and other Dali
model objects). The methods are all declared in o.e.jpt.utility.model.Model.

Use addPropertyChangeListener(...) if you are interested in simple properties (e.g. 'name', 'mapping').

Use addCollectionChangeListener(...) if you are interested in an attribute of the model that contains
a collection of other objects (e.g. 'jpaFiles' in JpaProject). Collections are used when order is insignificant.

Use addListChangeListener(...) if you are interested in
an attribute of the model that contains a
(order-sensitive) list of other objects (e.g. 'attributes').

There are 2 other types of listeners, "state" and "tree", that are rarely, if ever, used in Dali.

Hopefully, the method names and Java doc on the listener interfaces and event classes are
straightforward enough to get you started.

Brian


Back to the top