for the session bean part....the snippet is like this...
public User createDoc(Site site, User user)throws ServiceException{
IResult result = null;
try{
if(db != null){
db.close();
if(log.isDebugEnabled()){
log.debug("[LRB] Database is close in createDoc
method");
}
}
db = odmg.newDatabase();
db.open(site.getDbConnectionAlias(),Database.OPEN_READ_WRITE);
//get the current transaction from the container
Transaction tx = odmg.currentTransaction();
//broker = ((TransactionImpl)tx).getBroker();
//broker = getBroker(new PBKey(site.getDbConnectionAlias()));
broker = ((HasBroker)tx).getBroker();
Criteria cri = new Criteria();
cri.addEqualTo("label",user.getLabel());
Query query = QueryFactory.newQuery(User.class, cri);
Collection userExist = broker.getCollectionByQuery(query);
if(!userExist.isEmpty()){
result = user.getResult();
String msg = "The following " + user.getLabel() + " already
existed.";
result.addMessage(msg);
result.setValidity(IResult.SAVED_FAILED);
return user;
}
tx.lock(user,Transaction.WRITE);
//db.makePersistent(document);
result = user.getResult();
result.setValidity(IResult.SAVED_SUCCESS);
result.addMessage("Document \"" + user.getLabel() + "\" saved
successfully.");
}catch(LockNotGrantedException ex){
throw new ServiceException(
"Failed to save Log Receiving document with label "
+ user.getLabel());
}catch(PersistenceBrokerException ex){
throw new ServiceException(
"Failed to save Log Receiving document with label "
+ user.getLabel());
}
catch(ODMGException ex){
throw new ServiceException(
"Failed to save Log Receiving document with label "
+ user.getLabel());
}
return user;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]