Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DB updated on quering the Entity getMethod?

 
Nilesh Nadiyana
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
a trivial question:
Does accessing a quering method say myentity.getStatus() would cause the DB trigger(insert/update) to be fired?
<snip>
myentity = myentityhome.findby(id);
myentity.getStatus();
<snip>
Regards,
Nilesh.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't say, really. It depends on whether the result is returned from a cache.
 
Nilesh Nadiyana
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for response. However, How do I know whether the cache is enabled or it is coming from cache?
I am using weblogic 4.5.1.
The problem is :
we have a servlet.
From the servlet, It finds an entity bean based on id. (somehow session has it).
checks whether the status of the found bean (record) is "cancel" and throws an "application exception" (kind of validation).
However, At the end of this operation, the lastediteddate of the table gets updated to system date. This is due to execution of a trigger which says:
on insert/update of table, update last edited date to sysdate.
This means, the trigger gets fired. But the code does not do any update ("Set" methods).
Thanks in advance for clarifying my doubt.
Regards,
Nilesh.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I didn't get (pun intended ) that you were talking about only a get method... I don't know why WebLogic 4.5.1 makes an UPDATE even though you're only querying the entity. You probably have double-checked that the trigger is not executed on SELECTs as well, right?
I'd suggest turning to BEA forums/support.
[ December 15, 2003: Message edited by: Lasse Koskela ]
 
JeanLouis Marechaux
Ranch Hand
Posts: 906
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lasse Koskela:
I'd suggest turning to BEA forums/support.

If you can find someone with WebLogic 4.5.1 knowledge there !
It's quite an old version.
[ December 15, 2003: Message edited by: Jean-Louis Marechaux ]
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nilesh Nadiyana:
Does accessing a quering method say myentity.getStatus() would cause the DB trigger(insert/update) to be fired?

Calling the getFoo() method should not cause an update to occur. However, I was seeing this behavior (WebLogic 7.0.1) and found that it was my misunderstanding. I put a call to setModifiedDate() in my base entity bean's ejbStore() method after reading WebLogic's documantation that says that ejbStore() is called if the bean has been modified.
That turns out not to be the case, though -- instead ejbStore() is called as a result of the bean being involved in a transaction, whether or not the bean was modified. WebLogic's generated ejbStore() method first calls super.ejbStore(), then it checks to see if the bean has been modified and saves it to the DB if so.
Moral: make sure your ejbStore() method doesn't modify the bean or the bean will *always* be modified whenever it is involved in a transaction.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic