• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CMR relationship - ejbPostCreate

 
Adri Smith
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have read the HFE book but I still do not understand a pointregarding the relationships in entity beans. I do not know why we cannot set the relationships en ejbCreate and we have to make it in the ejbPostCreate.

In ejbCreate we have access to other beans.
Therefore I do not see why we have this restriction. Does anyone have an idea ?

I guess that is part of EJB law....

Thanks in advance,
Adri
 
sawan parihar
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
In ejbCreate() the entity doesn't have any identity. After the ejbCreate() call the container will insert the row in the database and will make the PK available. As there is no identity setting the cmr fields won't make sense.

If the bean in the relationship doesn't have a identity then you can see its strange relation .


Hope this helps.
[ June 30, 2005: Message edited by: sawan parihar ]
 
Adri Smith
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First I would like to tank you for your quick reply.

Ok I see the logic behind but I still do not understand why that would not be technically possible.

An sql insert is done just after the ejbCreate and in the ejbCreate we must have given the primary key and so on. But why can't we not give the relationship already.

In a database we can make it in one sql statement so why not in this case ?

Thx buddy,
Adri
 
sawan parihar
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I won't say that technically it is not possible but this is what the spec dictates. The EJB containers are implemented like this only. There are many places in specs where you will come up with these kinda questions atleast when I was reading specs many questions came in my mind but then it all boils down to one thing and that is "what the spec says".


Cheers
 
Adri Smith
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.

This is clearer in my mind. Sometimes we are trying too much to find a reason why we are allowed to do things and not others and so on....

I will sleep better

Good luck if you are preparing for the SCBCD,
Adri
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic