-
-
2. Re: Unknown-pk usage ?
roger_cmu May 5, 2004 9:25 AM (in response to sesques)Hi Pascal,
My comments are not answers to your questions. Rather I am asking the same question in a different fashion.
Look at the quesion posted by author 'KarstenTS':
I'm trying to get an CMP EntityBean startet that should have an auto-generated primary-key, an auto-incremented Integer.
I'm not sure why resort to unknown-pk to solve the issue of
1- auto generated primary key
2- auto increment integer
I had similar situation and it was solved without resorting to unknown-pk. The solution was posted at jboss forum at javaranch http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=63&t=000783.
I feel I am missing something here because I see a lot of postings related to unknown-pk trying to solve the above mentioned issues.
Any thoughts.
- Roger -
3. Re: Unknown-pk usage ?
sesques May 5, 2004 9:44 AM (in response to sesques)Thanks Roger,
I agree with you. The auto generated primary key issue is solved by:
1) the @jboss.persistence auto-increment = "true" tag for the primary key cmp field.
2) the @jboss.entity-command name = "(Database specific)" in the bean definition.
But it works also with:
1) @jboss.unknown-pk ... auto-increment="true" in the bean definition
2) @ejb.pk class = "java.lang.Object" in the bean definition
3) the @jboss.entity-command name = "(Database specific)" in the bean definition.
4) Not defining a cmp-field for the primary key.
BTW, JBoss don't care about the ejbCreate return type. In both cases, I return a java.lang.Object and it works fine.
So the question is what's the difference, and what is the uses cases for each method ?
I think that only a JBoss guy can respond ;-)
Pascal -
4. Re: Unknown-pk usage ?
aloubyansky May 6, 2004 3:02 AM (in response to sesques)There is a paragraph in the spec 'special case: unknown priamry key'.
The point is that you might not know for sure the pk (which is automatically generated) type in the deployment environment and you don't care.
But in practice it seems to be a rare case and you can make any unknown pk to be a 'known' one and have a typed accessor. -
5. Re: Unknown-pk usage ?
sesques May 7, 2004 5:32 AM (in response to sesques)Thanks very much Alex.
This is more clear for me.
Pascal