That's not really how CMP's work. Just make a BMP instead, it'll be small, and to be quite honest, there will be less lines of code than a CMP if you include descriptors.
Oh, another option if you already have CMPs defined for that table is to create a Home method in the CMP. This can just be count incrementor for every load... it's in the 2.0 spec.
i don't understand the second suggestion.
Can you explain it better?
Thank you very much.
A home method in a entity bean is a method in a object instance that is not associated with a specific primary key yet (or ever). Finder methods are like this.
What you can do is create a singleton, accessable from a home method, that can do one of two things. One, simply keep a value that gets incremented by the entity on every create (therefore in essance counting the number of rows), or that uses some QL call against the beans to get the count (in which case you wouldn't need the singleton) which in essance would just be another finder method, with a select (*) in it.