1> In strict EJB CMP, you need to declare a key class for every Entity Bean. don't worry, advanced EJB design tool like WSAD will generate it for you automatically.
2> in EJB2.0 you can't, that's why both weblogic and websphere has their proprietory extension in current product. EJB2.1 introduce dynamic EJB SQL, but you have to wait
3> Fetch in block is a very broad topic, we should fork a seperate thread for that. To answer you question straightly, you can't relay on SQL today, nor recommended in future. On positive side, most CMP has smart incremental fetch.
CMP is future, I see it making process every year, all of its regulations are tool friendly, but not human friendly, so find a better tool is important, unfortunately none of them exist for the time being. I can guranttee your failure if you apply them on large project today.
Best bet today is having your own "CMP": means seperate your business logic with persistent logic, handle later one by your own framework or one of many existing products such as expresso, castor etc.
另外对于第3点有不同意见,Quote:"you can't relay on SQL today":
我们应该发挥各种database的特性,针对不同的db写一些不同的实现定位的sql语言,比如Oracle用rownum,Mysql用Limit等等.还有不同的db的实现automatic key的方式也不一样,我们还是得写不同的sql.除非等到这些都成为标准sql的一部分,我们程序员才能舒服一点,we have to relay on SQL today, because performance is important in most projects.
I was not clear or precise about my comment about using DB dependent SQL: I mean don't try to use them within CMP.
Idealy it's the job of container to automatically generate DB dependent sql for best performance, to my knowledge, some persistence engines such as Websphere5, toplink already can take advantage of native db features to handle locking, auto number outer join etc. You make some declaration regardless of underlying db.
When can we see all the nice features becomes generic across allCMP, don't know, just think about how long it took SUN to add LOB and auto number handling APIs into JDBC.