Hi!
I quite don't understand why I have to call em.refresh(entitybean) in every
funtion of a stateful session bean that trys to modify bean values. Maybe
someone can give me a pointer. This is my code (non-important columsn snipped)
| Entity(access=AccessType.FIELD)
| @Table(name="myentity")
| public class MyEntity implements Serializable {
|
| @Id(generate = GeneratorType.AUTO)
| private Long id;
|
| @Column
| private Boolean seen;
|
| // getters and setters ommitted
|
| @Override
| public boolean equals(Object o) {
| if (o instanceof MyEntity) {
| MyEntity p = (MyEntity) o;
| if (p.getId().equals(this.getId()))
| return true;
| else
| return false;
| }
| return false;
| }
|
| @Override
| public int hashCode() {
| return this.id.hashCode();
| }
|
| }
|
The stateful session bean is saving a local copy of the used MyEntity in its
state:
| @Stateful
| @Remote
| @SecurityDomain("other")
| public class BusinessManagerBean implements BusinessManager, Serializable {
|
| @PersistenceContext(unitName="mypersistencecontext")
| EntityManager em;
|
| private MyEntity entity;
|
| // part of the remote interface
| public boolean createNew() {
| entity = new MyEntity();
| entity.setValue(true);
| em.persist(entity);
|
| // the following change will automatically propagated to the
database
| entity.setValue(false);
| return true;
| }
|
| // public remote interface function
| public boolean doBusinessLogic() {
| // em.refresh(entity);
| // change not propagatec to database unless the above em.refresh()
is commented out
| entity.setValue(true);
| return true;
| }
| }
|
|
The entity is not detached from the database (e.g. em.remove(entity) works
flawlessly). However, I have no idea why I have to em.refresh() it each time.
(I tried adding em.flush() at various places with no success).
The above is only a small testcase of mine that still shows this behaviour. In
reality, the MyEntity has a HUGE datagraph within ManyToMany/OneToMany
relationships, and calling em.refresh() each time takes a copule of seconds, so
as you can image it's inacceptible for me to call em.refresh() in every singe
business function.
Thanks for any pointers.
Alex
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3922378#3922378
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3922378
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user