users@glassfish.java.net

Re: General question about detachable EJB 3.1 entities

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Fri, 22 Jan 2010 14:31:51 -0800

I think you are mixing EJBs and JPA Entities. Did you look at Java EE
Tutorial?

Regards,
-marina

glassfish_at_javadesktop.org wrote:
> Hi,
>
> I've got a general question about detaching an entity and sending it towards to the client by using some session bean.
>
> Let's imagine the following example... I've got an entity, let's say called BankAccountEntity, which consists of getters and setters for its attributes. Further it has got a [i]isValid()[/i] method to validate the account number for correctness. In the [i]isValid()[/i] method e.g. an 3rd party library will be used doing the necessary calculation.
>
> When talking about detaching an entity, I will be thinking of something like this:
>
> Client Code:
> BankAccountFactoryRemote bacf = (BankAccountFactoryRemote) initialCtx.lookup(...);
> BankAccount b = bacf.newBankAccount();
>
> Code in the Session Bean:
> public BankAccount newBankAccount() {
> return new BankAccountEntity();
> }
>
> Of course, BankAccountEntity is implementing the BankAccount interface, which is used at the client.
>
> If the entity now gets detached (transferred to the client by using serialization) and the client works with the object by only knowing the interface, what actually happens to the isValid() method call... will it be executed locally at the client (as all the bytecode required will also be transferred to the client at time of detachment) or will calling isValid() at the client result in an RPC call and the isValid() method is executed at the application server?
>
> What is the recommended approach for such situations, should such a [i]isValid()[/i] method gets outsourced to the session bean or is it common to have it in the entity class?
>
> I'm looking forward to some enlightment... :-)
> [Message sent by forum member 'anusplus' (anus.plus_at_gmx.de)]
>
> http://forums.java.net/jive/thread.jspa?messageID=382219
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>