This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes J2EE - Entity & Entity Listeners  usage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "J2EE - Entity & Entity Listeners  usage" Watch "J2EE - Entity & Entity Listeners  usage" New topic

J2EE - Entity & Entity Listeners usage

satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
I am a newbie in J2EE.

When i was going through the Entity listeners, the declaration looks like

Instead i expect the otherway round, it should be like

I feel the second approach is extendable, say for example, if i want to write a new listener for the existing entities, it would be easy to do it in the second approach. All i have to do is that write a new listener class and associate all the entities that the new listener is willing to handle.

Can someone explain why it is done in the other way?

James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
Probably no good reason, just the way things ended up.

The events started as just annotating Entity methods, then the listeners were added, it was easiest just to add them as another annotation on the Entity, instead of having to introduce another type of annotated class.

I like your idea of annotating a EntityListener, perhaps suggest it to the spec group for a future release.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
I agree. Here's the link:
subject: J2EE - Entity & Entity Listeners usage
Similar Threads
A Newb JMS question - trying to use observer pattern with MDB onMessage?
How to write my own Event ( & Listener for it)??
What exactly the use of an interface other than readability of code?
Entity callback doubt
synchronised add and remove listener methods