Other interesting facets: it uses the Glassfish EJB3 reference implementation (as opposed to Hibernate 3, although it'd be interesting to see if the use of Hibernate changed anything in the walkthrough), and also references Java2DB, a tool provided in Glassfish that can create a database schema from a set of entity beans.

First let me say that I have read the spec and built a couple very small sample applications myself. Based on my expirence so far I really like EJB and think that the people involved did a great job bringing it together.

I'm also sure that once Rod and co. build a wrapper for EJB3 that the spring people will be fine with it too ;)

My question is weather there are plans for javax.persistence to become part of Java SE? It seems to me that all of Java could benefit from this API not just application server based applications.

The Java Persistence API spec (JPA 1.0) is actually a separate and distinct spec from EJB 3.0, and EJB 3.0 refers to JPA for its POJO persistence model. One reason the two were separated into individual specs (though produced by the same expert group) was precisely so JPA could become part of JavaSE at some point. (There was a very conscientous effort to make sure that JPA, as defined in the spec, could be used in either SE or EE environments.) It also helps separate the concepts of the persistence model (JPA) from the component execution model (EJB3). This is good, since these two models being smashed together in EntityBeans was one of the factors EB's started to be viewed as 'heavyweight'.

Hey, the name EJB3 has been overly sold to the developer community as the POJO persistence solution for so long, it is too late to correct the mistake. Even though the acronym POJO itself was coined by Martine Fowler et al to make using plain Java object instead of heavyweight EJB more sexy (thus more attractive to developers who want to be sexy).

Hey, the name EJB3 has been overly sold to the developer community as the POJO persistence solution for so long, it is too late to correct the mistake.

OTOH POJO persistence has been oversold, too. After having to choose between 5+ MB of generated SQL queries or writing a separate finder for each access case in a proprietary language with shabby tool support, plain old SQL doesn't look that bad anymore.

I have implemented an EJB3 persistence unit, I've read most of the released documents regarding EJB3 persistence, from both Sun and JBoss, and I have these comments.

1. Very nice, clear and helpful article. Thank you Sanjeeb.

2. Hibernate-EJB3 docs reference a ".ejb3" file which encompasses the persistence unit. Sanjeeb implies this file can be in a simple .jar file. Let me say "massive thank you" to whoever is responsible, if in fact EJB3s can be captured in a simple JAR. The packaging issues for ".ejb3" were going to be pretty annoying.

3. The em.find method was not well documented in Hibernate-EJB3 docs, so it was nice to see it used here.

4. I didn't know that @Id was required, and that it was mentioned in the article saved me some time.

5. Just a plug for the Hibernate-EJB3 folks: That microcontainer is way-nice for debugging these EJB3 entity beans.

What can we do to encourage the release of this great persistence technology?

QUESTION: Is it true that ".par" is no longer necessary to indicate a persistence archive? (Please.) The presence of a persistence.xml file should be enough to trigger examining annotations, and the extra deployment complexity of dealing with .par using Maven, etc. will hinder adoption.

QUESTION: Is it true that ".par" is no longer necessary to indicate a persistence archive? (Please.) The presence of a persistence.xml file should be enough to trigger examining annotations, and the extra deployment complexity of dealing with .par using Maven, etc. will hinder adoption.

This is correct. ".par" as a packaging identifier was proposed in one of the earlier versions of the spec, but in the latest spec version, any .jar file containing a persistence.xml file identifies to the EE runtime that the .jar should be examined for entity annotations and xml persistence attributes. (The persistence.xml file identifies which classes within the .jar belong to each Persistence Unit defined for that jar.) In an SE environment, the classes that define the persistence unit are identified to the EntityManager through config parms passed in when the EntityManager is created.

QUESTION: Is it true that ".par" is no longer necessary to indicate a persistence archive? (Please.) The presence of a persistence.xml file should be enough to trigger examining annotations, and the extra deployment complexity of dealing with .par using Maven, etc. will hinder adoption.

This is correct. ".par" as a packaging identifier was proposed in one of the earlier versions of the spec, but in the latest spec version, any .jar file containing a persistence.xml file identifies to the EE runtime that the .jar should be examined for entity annotations and xml persistence attributes. (The persistence.xml file identifies which classes within the .jar belong to each Persistence Unit defined for that jar.) In an SE environment, the classes that define the persistence unit are identified to the EntityManager through config parms passed in when the EntityManager is created.Randy

Is this also true for the .ejb3 suffix for Session Beans? Does JBoss support .jar suffix for EJB3 Session Beans? Let me continue this highly moral author trend and say that I declare my undying love to those responsible, if .jar is a fine suffix for EJB3 Session Beans!

Yes, it is true for EJB3 session beans as well. It is implemented in glassfish project..ejb3 was always a JBoss specific thing, never got into the spec. .par was introduced in the EJB3 spec. But it was subsequently removed.

Is this also true for the .ejb3 suffix for Session Beans? Does JBoss support .jar suffix for EJB3 Session Beans? Let me continue this highly moral author trend and say that I declare my undying love to those responsible, if .jar is a fine suffix for EJB3 Session Beans!

Thank you, Dan. You possess great moral codes to approach authors. Not everyone possesses what you do in this direction.You illustrated a good method when publishing. I wish, we all illustrate the same (good method) (here on TSS) when posting questions.Good.

2. Hibernate-EJB3 docs reference a ".ejb3" file which encompasses the persistence unit. Sanjeeb implies this file can be in a simple .jar file. Let me say "massive thank you" to whoever is responsible, if in fact EJB3s can be captured in a simple JAR. The packaging issues for ".ejb3" were going to be pretty annoying.

This is already (and has always been) implemented in Hibernate Entity Manager (ie the simple jar stuff). I should make it clearer from the doc.

3. The em.find method was not well documented in Hibernate-EJB3 docs, so it was nice to see it used here.

In my original posting, I mentioned that because of a bug, Java2DB (i.e. automatic table creation during deployment) feature does not work in glassfish for Derby database. Very soon, the bug is going to be fixed. It is right now only working for Oracle database. To enable it, either

1) add a property in persistence.xml under <properties> tag as follows:<property name="ddl-generation" value="createtables"/>

TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations technology projects - with its network of technology-specific websites, events and online magazines.