Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CMP 2.0 doesn't write into db

 
Ingi Gauti
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i'm having a problem with ejb2.0 entity beans ( i'm currently running on j2ee ri v1.3 ). the problem is this i've created a very simple entity bean just 4 fields, the deploy tool works fine and the bean deploy's correcly. the table related to this bean is created correctly.
i have then constructed a simple client and created an instance of the bean which also works correctly, there are no error's on the back end, and no errors in the db logs.
now here's the bit that's driving me mad, the data is never written to the database. i can find the bean again by using findByPrimaryKey and it reterives the bean instance correctly i can modify the data held by the bean, but if i shut down the j2ee and restart it the bean is lost.
any help on this would be greatly appricated
regards
 
Ingi Gauti
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For those who are interested in the answer, I didn't do the setEntityContext and unsetEntityContext methods, it should be like this
public void setEntityContext(EntityContext ctx) {
ejbContext = ctx;
}
public void unsetEntityContext() {
ejbContext = null;
}
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ingi Gauti:
For those who are interested in the answer, I didn't do the setEntityContext and unsetEntityContext methods, it should be like this
public void setEntityContext(EntityContext ctx) {
ejbContext = ctx;
}
public void unsetEntityContext() {
ejbContext = null;
}

You require this, since EntityContext allows your Beans to know about the environment.
- Sandeep
 
Anjali Paradkar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing the same problem. I have put in the setEntityContext and unsetEntityContext methods, as suggested in the previous post. However, the problem still persists.
 
Marco Barenkamp
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
data will be written into database, when the server
invokes the ejbStore Method. This method is called after commiting the transaction.
Make sure that the appropriate methods do have the 'REQUIRED' property for transaction at least.

------------------
Marco Barenkamp
____________________________________________
L M I N T E R N E T S E R V I C E S AG
Senior Trainer & Architect,
BEA Certified Enterprise Developer
Sun Certified Programmer for the Java2 Platform
Sun Certified Web Component Developer for the Java2 Platform
Sun Certified Developer for the Java 2 Platform
Sun Certified Enterprise Architect for the Java 2 Platform Enterprise Edition (PI)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic