I've been building a new system with Java EE 5, particularly GlassFish which is the open source version of Sun Application Server, and have come away with a few thoughts.
First of all, Java EE (formerly J2EE) has come a long way. A real long way. Obviously someone noticed a lot of mindshare gravitating towards simpler persistence frameworks (Hibernate), so it's good to see movement on making things easier for the developer as opposed to the god-awful tediousness of multiple interface and XML configuration files. Of course, this is all possible due to annotations in Java 5.
On the down side, you still need to include a web.xml file with ejb-local-ref tags in your .war file, even if they are packaged in an .ear with your EJBs. I initially expected the container to know I was referencing an EJB in the same container because there's an annotation for it: @EJB, so I had a dickens-of-a-time solving "why doesn't this work??"! More time googling, I suppose...
Another problem is with auto-incrementing fields in your database. Of course now you can actually use them, and define them as such with the correct annotation: @Id. The issue is that there is another annotation you use that defines the strategy the container uses to arrive at the newly generated id, @GeneratedValue, and the value is pretty much driven by the database in the backend:
// auto-incrementing field for Oracle @Id @GeneratedValue( strategy = GenerationType.SEQUENCE, generator="mynew_seq" ) @SequenceGenerator( name="mynew_seq" ) private Long id; // auto-incrementing field for SQL Server @Id @GeneratedValue( strategy = GenerationType.IDENTITY ) private Long id;
So, it's not a huge deal to migrate from one database to another -- but you have to edit the source code, which seems like a big no-no to me. You can see this would become a big pain if, for example, testing on MySQL and deploying to Oracle in production. There's a configuration file called persistence.xml to let the container know what database you're using, so I don't see why you can't define those kind of relationships there instead of in the source code.

fun-java-ee-5/add_comment