ejb@glassfish.java.net

Re: Need a reference to an Session Bean within an Entity Bean

From: Kem Elbrader <kem.elbrader_at_gmail.com>
Date: Tue, 31 Jul 2007 14:46:22 -0600

Here's the situation.

A company uses a database that stores information about its customers.
A web interface is available for customer service representatives to
update the customers name, phone number, etc. The web interface is not
suitable for customers to use so the company has a calling center that
enables the customers to request changes. The database and web
interface were produced by a third party which is unwilling to make
changes to the existing system. The third party does provide a web
service with operations to create, update, and delete the data.

The company wants to provide a web interface to allow customers to
update their information themselves. Further, the company wants to
produce additional services which will require extra data that is not
stored in the original database. For example, some of the entities
represented in the original database simply need some properties added
to them. It's not viable to reproduce the existing system. So a new
system must be created that is capable of updating the data in the
existing system, persist the new data and provide the new
functionality.

I was hoping I could use JPA to model the new and old data together so
that a single object could be used in the cases where simple
properties need to be added to the existing entities. Is this
reasonable?

Here is my current approach.

@Entity
@EntityListeners({UserListener.class})
class ExampleUser {
    @Id String login; // new data
    @Transient String name; // existing data

    String getLogin() { return login; }
    void setLogin(String login) { this.login= login; }

    String getName() { return name; }
    void setName(String name) { this.name = name; }
}

class UserListener {
    @PostLoad void initializeUser(Object entity) {
        // use web service to obtain the users name
        // copy the name to ExampleUser.name
    }
    @PostPersist void saveUser(Object entity) {
        // use web service to save ExampleUser.name
    }
}

On 7/31/07, Eve Pokua <gorgeous65_at_msn.com> wrote:
>
> Kem,This type of injection is usually done with the client to tellit which of the remote interface is being reference to such client. What are you trying to achieve?eve> Date: Mon, 30 Jul 2007 12:22:31 -0600> From: kem.elbrader_at_gmail.com> To: persistence_at_glassfish.dev.java.net; ejb_at_glassfish.dev.java.net> Subject: Need a reference to an Session Bean within an Entity Bean> > Is it possible to inject an EJB into an Entity? If not is there> another way to get a reference to a EJB from an Entity?> > Example:> > @Entity> public class Customer {> > @EJB> CustomerAction customerAction;> > @PostLoad> void initialize() {> // do stuff with customerAction...> }> }> > ---------------------------------------------------------------------> To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net> For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net>
> _________________________________________________________________
> Feel like a local wherever you go with BackOfMyHand.com
> http://www.backofmyhand.com
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
>
>