ejbSelect and ejbFind have three options:
1. return a single object reference
2. return java.util.Collection
3. return java.util.Set
No other option is allowed. I didn't see anything in the spec that said what would happen if you want a single object reference but you wrote a query that would sometimes finds multiple items. Since the queries will typically get mapped into
JDBC calls, you'd expect to get whatever the database happened to choose as the first row of the ResultSet; anything else would be pointlessly inefficient (because the container wouldn't know which row you wanted, so any choice of row is as good as any other - the container may as well be wrong and fast instead of wrong and slow).
Sun reasonably could argue that it isn't the
EJB spec's job to overly describe what happens when the bean isn't implemented correctly, any more than the
Java language spec spends effort on describing the consequences of coding bugs. Getting the EJB-QL correct so that it finds only one item when you only expect one item is necessarily part of the bean provider's (as the EJB-QL writer) and deployer's (in setting up the database) jobs. Bugs probably aren't intended to be overly portable. :-)