users@glassfish.java.net

Re: Surprising JPA (Toplink) Behaviour (glassfish v1 UR1)

From: <glassfish_at_javadesktop.org>
Date: Sun, 18 Mar 2007 15:20:36 PST

The big difference between the two mechanisms is that one of them relies upon annotation processing.

If you were deploying to Tomcat for instance in a JAX-WS web service and wanted to use the annotation, then you might very well find yourself entirely out of luck.

My understanding of the process is this:
You deploy the Webservice (eg to Tomcat)
The JAX-WS aware annotation processor goes "oh! I know what this is!" and it processes the JAX-WS annotations. (Produces the WSDL etc)
The JAX-WS aware annotation processor hits the EJB 3.0 annotation for injecting the EJB 3.0 Persistence Unit. It goes "I have no fscking clue what this horrible thing is".
The JAX-WS aware annotation processor pitches a fit, tosses its toys out of the cot and/or spits the dummy.
This is a bad thing (tm).

Now you might say "that sucks! JAX-WS is stupid". However, this seems to be a limitation with annotations, you may or may not be able to mix different kinds of annotations, depending on how the system will be delivered.

Additionally, not having to write your own WSDL is such an enormously huge benefit, that it massively outweighs any other disadvantages, such as having to slap in 2-3 extra lines of code per EJB driven sertvice. (And it is boiler plate code, so there are OO ways of handling it anyway).

-------

Recommendations:

(1) have a look into the Hibernate (JBoss??) Tree Cache - a cache distributed across multiple machines.

(2) EJB 3.0 has (if I remember correctly) a veritable plethora of ways to check if the write/read is working with dirty data, which may be worth investigating. I think you have to add a number or a timestamp to each row in the database, and then every time you do a write it checks to make sure that you are dealing with the most recent timestamp, if not it assumes it is dirty, bad, evil and wrong (tm).

See also:

EntityManager.refresh(Object)

refresh
void refresh(Object entity)Refresh the state of the instance from the database, overwriting changes made to the entity, if any.

Parameters:
entity -
Throws:
IllegalStateException - if this EntityManager has been closed.
IllegalArgumentException - if not an entity or entity is not managed
TransactionRequiredException - if invoked on a container-managed entity manager of type PersistenceContextType.TRANSACTION and there is no transaction.
EntityNotFoundException - if the entity no longer exists in the database.
[Message sent by forum member 'rickcarson' (rickcarson)]

http://forums.java.net/jive/thread.jspa?messageID=208641