This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
According to the book, it is not and I cannot figure out what is wrong? Well, I am aware that most likely, that method needs to have some parameters, but in theory it can be very well without any. Also it does not need to be named �Create<something>, just Create should be OK as well. This in the home interface, of course. The correct one as per the book is this one:
theres' another thread on the same issue in this forum
Joined: Oct 03, 2005
there. i found it.
check spec chap 10.6.13
the class must provide suitable implementaiton of hte hashCode and equals(OBject)
so, it cannot be a primitive.
I know, i missed that too.. got answer from checking spec/forum. I don't think this particularity is explained in HFEJB
Joined: Nov 09, 2006
Thanks for your answer Marco! I think I understand that, but that would apply only if the primary key must be class, and this of course in the case where primary key is comprised of more then one attribute, field, piece of data, name it whatever you like. So we have two cases for the primary key issue. In the simplest possible case, the primary key is only single field (let me put that in database terms to make it simple). And in that case we DO NOT need a class, spec is clear about this. So in that case, I have not found anywhere in the spec where it says that primary key data type CANNOT be primitive, like �int�. The spec does say that it is allowed for the primary key data type to be undefined or deferred until deploy time and in that case you are supposed to put Object as the data type. So, is there any guru to explain this to me please?
when it is "int" how would you define in the dd the primary key ?
With Regards,<br /> Rajan<br />"Java Rocks"
Joined: Nov 09, 2006
OK, I agree there is <prim-key-class> in the DD, but even with that I was not sure. Since the container figures out the types for persistent fields based on abstract getters and setters in the bean class, I was not sure is this <prim-key-class> is mandatory if for example there is no need for the class, in the case where only one field is enough, so <primkey-field> might have been enough. But then, it came to my mind that you must return null from ejbCreate() which is a sure sign that return data type must be an object and not a primitive. Anyway, Rajan, thanks for the pointer.