Hi,
I have changed to use MySql instead and all works fine. So it seems taht
geronimo is not working with MaxDB.
kind regards
Joachim
Joachim Tessmer schrieb:
> Hi,
>
> I have debugged the code, no exception is thrown. I'm using the MaxDB
> Database (hosted bya MySQL). Reading data works fine but after
> creating no records will be inserted in the DB.In the Attchment you
> find the code to create a new Task.
>
> For the moment I'm using MaxDB, I will try to use MySQL instead.
>
> kind regards
> Joachim
>
> Gianny Damour schrieb:
>> Hello Joachim,
>>
>> This problem may be due to a transaction rollback. Are you sure that
>> the transaction is committed? Also, could you please tell me the type
>> of primary key generator that you are using?
>>
>> Thanks,
>> Gianny
>>
>>
>> On 23/10/2006, at 7:10 AM, Joachim Tessmer wrote:
>>
>>> Hi,
>>>
>>> I have problems using CMP with Entitybeans, After calling create it
>>> seems the bean is ok (seraching for it finds the new component) and
>>> has the primary key from a sequence inside the DB, but the record
>>> itself is never written to the DB. Any Ideas?
>>>
>>> kind regards
>>> Joachim
>>
>>
> ------------------------------------------------------------------------
>
> /**
> *
> */
> package de.schleichy.softplan.ejb.entity;
>
> import java.rmi.RemoteException;
> import java.util.Collection;
>
> import javax.ejb.EJBException;
> import javax.ejb.EntityContext;
> import javax.ejb.RemoveException;
>
>
>
>
>
> /**
> * <!-- begin-xdoclet-definition -->
> * @ejb.bean name="User"
> * jndi-name="java:comp/env/ejb/User"
> * local-jndi-name="java:comp/env/ejb/UserLocal"
> * type="CMP"
> * primkey-field="id"
> * schema="UserSCHEMA"
> * cmp-version="2.x"
> *
> * @ejb.persistence
> * table-name="SOCKE.USER"
> *
> * @ejb.finder
> * query="SELECT OBJECT(a) FROM UserSCHEMA as a"
> * signature="java.util.Collection findAll()"
> *
> * @ejb.finder
> * query="SELECT OBJECT(a) FROM UserSCHEMA as a WHERE a.login = ?1"
> * signature="java.util.Collection findByName(java.lang.String login)"
> *
> * @ejb.pk class="java.lang.Integer"
> *
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> **/
>
> public abstract class UserBean implements javax.ejb.EntityBean {
>
> /**
> *
> * <!-- begin-user-doc -->
> * The ejbCreate method.
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.create-method
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public java.lang.Integer ejbCreate() throws javax.ejb.CreateException {
> // EJB 2.0 spec says return null for CMP ejbCreate methods.
> // TODO: YOU MUST INITIALIZE THE FIELDS FOR THE BEAN HERE.
> // setMyField("Something");
> // begin-user-code
> return null;
> // end-user-code
> }
>
> /**
> * <!-- begin-user-doc -->
> * The container invokes this method immediately after it calls ejbCreate.
> * <!-- end-user-doc -->
> *
> * @generated
> */
> public void ejbPostCreate() throws javax.ejb.CreateException {
> // begin-user-code
> // end-user-code
> }
>
> /**
> *
> *
> * <!-- begin-user-doc -->
> * CMP Field id
> *
> * Returns the id
> * @return the id
> *
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> *
> * @ejb.persistent-field
> * @ejb.persistence
> * column-name="ID"
> * jdbc-type="INTEGER"
> * sql-type="INTEGER"
> * read-only="false"
> * @ejb.pk-field
> *
> * @ejb.interface-method
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract java.lang.Integer getId();
>
> /**
> * <!-- begin-user-doc -->
> * Sets the id
> *
> * @param java.lang.Integer the new id value
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.interface-method
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract void setId(java.lang.Integer id);
>
> /**
> *
> *
> * <!-- begin-user-doc -->
> * CMP Field login
> *
> * Returns the login
> * @return the login
> *
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> *
> * @ejb.persistent-field
> * @ejb.persistence
> * column-name="LOGIN"
> * jdbc-type="VARCHAR"
> * sql-type="VARCHAR() ASCII"
> * read-only="false"
> *
> *
> * @ejb.interface-method
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract java.lang.String getLogin();
>
> /**
> * <!-- begin-user-doc -->
> * Sets the login
> *
> * @param java.lang.String the new name value
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.interface-method
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract void setLogin(java.lang.String login);
>
> /**
> *
> *
> * <!-- begin-user-doc -->
> * CMP Field password
> *
> * Returns the password
> * @return the password
> *
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> *
> * @ejb.persistent-field
> * @ejb.persistence
> * column-name="PASSWORD"
> * jdbc-type="VARCHAR"
> * sql-type="VARCHAR() ASCII"
> * read-only="false"
> *
> *
> * @ejb.interface-method
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract java.lang.String getPassword();
>
> /**
> * <!-- begin-user-doc -->
> * Sets the password
> *
> * @param java.lang.String the new name value
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.interface-method
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract void setPassword(java.lang.String password);
>
> /**
> *
> *
> * <!-- begin-user-doc -->
> * CMP Field name
> *
> * Returns the name
> * @return the name
> *
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> *
> * @ejb.persistent-field
> * @ejb.persistence
> * column-name="NAME"
> * jdbc-type="VARCHAR"
> * sql-type="VARCHAR() ASCII"
> * read-only="false"
> *
> *
> * @ejb.interface-method
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract java.lang.String getName();
>
> /**
> * <!-- begin-user-doc -->
> * Sets the name
> *
> * @param java.lang.String the new name value
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.interface-method
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract void setName(java.lang.String name);
>
> /**
> *
> *
> * <!-- begin-user-doc -->
> * CMP Field pre_name
> *
> * Returns the pre_name
> * @return the pre_name
> *
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> *
> * @ejb.persistent-field
> * @ejb.persistence
> * column-name="PRE_NAME"
> * jdbc-type="VARCHAR"
> * sql-type="VARCHAR() ASCII"
> * read-only="false"
> *
> *
> * @ejb.interface-method
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract java.lang.String getPreName();
>
> /**
> * <!-- begin-user-doc -->
> * Sets the pre_name
> *
> * @param java.lang.String the new pre_name value
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.interface-method
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract void setPreName(java.lang.String pre_name);
>
> /**
> *
> *
> * <!-- begin-user-doc -->
> * CMP Field email
> *
> * Returns the email
> * @return the email
> *
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> *
> * @ejb.persistent-field
> * @ejb.persistence
> * column-name="EMAIL"
> * jdbc-type="VARCHAR"
> * sql-type="VARCHAR() ASCII"
> * read-only="false"
> *
> *
> * @ejb.interface-method
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract java.lang.String getEmail();
>
> /**
> * <!-- begin-user-doc -->
> * Sets the email
> *
> * @param java.lang.String the new email value
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.interface-method
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract void setEmail(java.lang.String email);
>
> /**
> *
> *
> * <!-- begin-user-doc -->
> * CMP Field phone
> *
> * Returns the phone
> * @return the phone
> *
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> *
> * @ejb.persistent-field
> * @ejb.persistence
> * column-name="PHONE"
> * jdbc-type="VARCHAR"
> * sql-type="VARCHAR() ASCII"
> * read-only="false"
> *
> *
> * @ejb.interface-method
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract java.lang.String getPhone();
>
> /**
> * <!-- begin-user-doc -->
> * Sets the phone
> *
> * @param java.lang.String the new phone value
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.interface-method
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract void setPhone(java.lang.String phone);
>
> /**
> *
> *
> * <!-- begin-user-doc -->
> * CMP Field version
> *
> * Returns the version
> * @return the version
> *
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> *
> * @ejb.persistent-field
> * @ejb.persistence
> * column-name="VERSION"
> * jdbc-type="INTEGER"
> * sql-type="INTEGER"
> * read-only="false"
> *
> *
> * @ejb.interface-method
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract java.lang.Integer getVersion();
>
> /**
> * @ejb.interface-method
> * @ejb.relation name = "Task-User" target-ejb = "Task"
> * target-role-name = "Task-to-User"
> * role-name = "User-to-Task"
> * @return
> */
> public abstract Collection getTasks();
>
> /**
> * @ejb.interface-method
> * @param tasks
> *
> */
> public abstract void setTasks(Collection tasks);
>
>
> /**
> * <!-- begin-user-doc -->
> * Sets the version
> *
> * @param java.lang.Integer the new version value
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.interface-method
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract void setVersion(java.lang.Integer version);
>
> /* (non-Javadoc)
> * @see javax.ejb.EntityBean#ejbActivate()
> */
> public void ejbActivate() throws EJBException, RemoteException {
> // TODO Auto-generated method stub
>
> }
>
> /* (non-Javadoc)
> * @see javax.ejb.EntityBean#ejbLoad()
> */
> public void ejbLoad() throws EJBException, RemoteException {
> // TODO Auto-generated method stub
>
> }
>
> /* (non-Javadoc)
> * @see javax.ejb.EntityBean#ejbPassivate()
> */
> public void ejbPassivate() throws EJBException, RemoteException {
> // TODO Auto-generated method stub
>
> }
>
> /* (non-Javadoc)
> * @see javax.ejb.EntityBean#ejbRemove()
> */
> public void ejbRemove() throws RemoveException, EJBException,
> RemoteException {
> // TODO Auto-generated method stub
>
> }
>
> /* (non-Javadoc)
> * @see javax.ejb.EntityBean#ejbStore()
> */
> public void ejbStore() throws EJBException, RemoteException {
> // TODO Auto-generated method stub
>
> }
>
> /* (non-Javadoc)
> * @see javax.ejb.EntityBean#setEntityContext(javax.ejb.EntityContext)
> */
> public void setEntityContext(EntityContext arg0) throws EJBException,
> RemoteException {
> // TODO Auto-generated method stub
>
> }
>
> /* (non-Javadoc)
> * @see javax.ejb.EntityBean#unsetEntityContext()
> */
> public void unsetEntityContext() throws EJBException, RemoteException {
> // TODO Auto-generated method stub
>
> }
>
> /**
> *
> */
> public UserBean() {
> // TODO Auto-generated constructor stub
> }
>
> }
>
> ------------------------------------------------------------------------
>
> /**
> *
> */
> package de.schleichy.softplan.ejb.entity;
>
> import java.rmi.RemoteException;
>
> import javax.ejb.EJBException;
> import javax.ejb.EntityContext;
> import javax.ejb.RemoveException;
>
>
>
>
>
> /**
> * <!-- begin-xdoclet-definition -->
> * @ejb.bean name="Task"
> * jndi-name="java:comp/env/ejb/Task"
> * local-jndi-name="java:comp/env/ejb/TaskLocal"
> * type="CMP"
> * primkey-field="id"
> * schema="TaskSCHEMA"
> * cmp-version="2.x"
> *
> * @ejb.persistence
> * table-name="SOCKE.TASK"
> *
> * @ejb.finder
> * query="SELECT OBJECT(a) FROM TaskSCHEMA as a"
> * signature="java.util.Collection findAll()"
> *
> * @ejb.pk class="java.lang.Integer"
> *
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> **/
>
> public abstract class TaskBean implements javax.ejb.EntityBean {
>
> /**
> *
> * <!-- begin-user-doc -->
> * The ejbCreate method.
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.create-method
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public java.lang.Integer ejbCreate(String name, String desc, String prio) throws javax.ejb.CreateException {
> // EJB 2.0 spec says return null for CMP ejbCreate methods.
> // TODO: YOU MUST INITIALIZE THE FIELDS FOR THE BEAN HERE.
> // begin-user-code
> setName(name);
> setDesc(desc);
> setPrio(prio);
> return null;
> // end-user-code
> }
>
> /**
> * <!-- begin-user-doc -->
> * The container invokes this method immediately after it calls ejbCreate.
> * <!-- end-user-doc -->
> *
> * @generated
> */
> public void ejbPostCreate(String name, String desc, String prio) throws javax.ejb.CreateException {
> // begin-user-code
> // end-user-code
> }
>
> /**
> *
> *
> * <!-- begin-user-doc -->
> * CMP Field id
> *
> * Returns the id
> * @return the id
> *
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> *
> * @ejb.persistent-field
> * @ejb.persistence
> * column-name="ID"
> * jdbc-type="INTEGER"
> * sql-type="INTEGER"
> * read-only="false"
> * @ejb.pk-field
> *
> * @ejb.interface-method
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract java.lang.Integer getId();
>
> /**
> * <!-- begin-user-doc -->
> * Sets the id
> *
> * @param java.lang.Integer the new id value
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.interface-method
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract void setId(java.lang.Integer id);
>
> /**
> *
> *
> * <!-- begin-user-doc -->
> * CMP Field name
> *
> * Returns the name
> * @return the name
> *
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> *
> * @ejb.persistent-field
> * @ejb.persistence
> * column-name="NAME"
> * jdbc-type="VARCHAR"
> * sql-type="VARCHAR() ASCII"
> * read-only="false"
> *
> *
> * @ejb.interface-method
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract java.lang.String getName();
>
> /**
> * <!-- begin-user-doc -->
> * Sets the name
> *
> * @param java.lang.String the new name value
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.interface-method
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract void setName(java.lang.String name);
>
> /**
> *
> *
> * <!-- begin-user-doc -->
> * CMP Field desc
> *
> * Returns the desc
> * @return the desc
> *
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> *
> * @ejb.persistent-field
> * @ejb.persistence
> * column-name="DESC"
> * jdbc-type="VARCHAR"
> * sql-type="VARCHAR() ASCII"
> * read-only="false"
> *
> *
> * @ejb.interface-method
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract java.lang.String getDesc();
>
> /**
> * <!-- begin-user-doc -->
> * Sets the desc
> *
> * @param java.lang.String the new desc value
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.interface-method
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract void setDesc(java.lang.String desc);
>
> /**
> *
> *
> * <!-- begin-user-doc -->
> * CMP Field prio
> *
> * Returns the prio
> * @return the prio
> *
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> *
> * @ejb.persistent-field
> * @ejb.persistence
> * column-name="PRIO"
> * jdbc-type="VARCHAR"
> * sql-type="VARCHAR() ASCII"
> * read-only="false"
> *
> *
> * @ejb.interface-method
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract java.lang.String getPrio();
>
> /**
> * <!-- begin-user-doc -->
> * Sets the prio
> *
> * @param java.lang.String the new prio value
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.interface-method
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract void setPrio(java.lang.String prio);
>
> /**
> *
> *
> * <!-- begin-user-doc -->
> * CMP Field user
> *
> * Returns the user
> * @return the user
> *
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> *
> * @ejb.relation name = "Task-User" target-ejb = "User"
> * target-role-name = "User-to-Task"
> * role-name = "Task-to-User" target-multiple = "yes"
> * @ejb.persistence column-name="USER_ID"
> *
> * @ejb.interface-method
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract UserLocal getUser();
>
> /**
> * <!-- begin-user-doc -->
> * Sets the user
> *
> * @param java.lang.Integer the new user refernce
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.interface-method
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract void setUser(UserLocal user);
>
> /**
> *
> *
> * <!-- begin-user-doc -->
> * CMP Field version
> *
> * Returns the version
> * @return the version
> *
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> *
> * @ejb.persistent-field
> * @ejb.persistence
> * column-name="VERSION"
> * jdbc-type="INTEGER"
> * sql-type="INTEGER"
> * read-only="false"
> *
> *
> * @ejb.interface-method
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract java.lang.Integer getVersion();
>
> /**
> * <!-- begin-user-doc -->
> * Sets the version
> *
> * @param java.lang.Integer the new version value
> * <!-- end-user-doc -->
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.interface-method
> * <!-- end-xdoclet-definition -->
> * @generated
> */
> public abstract void setVersion(java.lang.Integer version);
>
>
> /**
> *
> */
> public TaskBean() {
> // TODO Auto-generated constructor stub
> }
>
> }
>
> ------------------------------------------------------------------------
>
> /**
> *
> */
> package de.schleichy.softplan.ejb.session;
>
> import java.rmi.RemoteException;
> import java.util.Collection;
> import java.util.Iterator;
> import java.util.List;
> import java.util.Vector;
>
> import javax.ejb.CreateException;
> import javax.ejb.EJBException;
> import javax.ejb.FinderException;
> import javax.ejb.SessionContext;
> import javax.naming.NamingException;
>
> import de.schleichy.softplan.ejb.entity.Task;
> import de.schleichy.softplan.ejb.entity.TaskData;
> import de.schleichy.softplan.ejb.entity.TaskHome;
> import de.schleichy.softplan.ejb.entity.TaskLocal;
> import de.schleichy.softplan.ejb.entity.TaskLocalHome;
> import de.schleichy.softplan.ejb.entity.TaskUtil;
> import de.schleichy.softplan.ejb.entity.User;
> import de.schleichy.softplan.ejb.entity.UserHome;
> import de.schleichy.softplan.ejb.entity.UserLocal;
> import de.schleichy.softplan.ejb.entity.UserLocalHome;
> import de.schleichy.softplan.ejb.entity.UserUtil;
> import de.schleichy.softplan.vo.TaskVO;
>
>
> /**
> *
> * <!-- begin-user-doc -->
> * A generated session bean
> * <!-- end-user-doc -->
> * *
> * <!-- begin-xdoclet-definition -->
> * @ejb.bean name="TaskMgr"
> * description="An EJB named TaskMgr"
> * display-name="TaskMgr"
> * jndi-name="java:comp/env/ejb/TaskMgr"
> * local-jndi-name="java:comp/env/ejb/TaskMgrLocal"
> * type="Stateless"
> * transaction-type="Container"
> *
> * @ejb.ejb-ref ejb-name="User" view-type="local" ref-local-name="ejb/UserLocal"
> * @ejb.ejb-ref ejb-name="Task" view-type="local" ref-local-name="ejb/TaskLocal"
> *
> * <!-- end-xdoclet-definition -->
> * @generated
> */
>
> public abstract class TaskMgrBean implements javax.ejb.SessionBean {
>
> /**
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.create-method view-type="remote"
> * <!-- end-xdoclet-definition -->
> * @generated
> *
> * //TODO: Must provide implementation for bean create stub
> */
> public void ejbCreate() {
> }
>
> /**
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.interface-method view-type="remote"
> * <!-- end-xdoclet-definition -->
> * @generated
> *
> * @ejb.transaction type="RequiresNew"
> *
> * //TODO: Must provide implementation for bean method stub
> */
> public List getTasks(Integer userId) {
>
> List tasks = new Vector();
>
> try {
> UserLocalHome home = UserUtil.getLocalHome();
> UserLocal user = home.findByPrimaryKey(userId);
> if(user!=null){
> Collection beanTasks = user.getTasks();
> Iterator it = beanTasks.iterator();
> while(it.hasNext()){
> TaskLocal task = (TaskLocal) it.next();
> TaskVO data = new TaskVO();
> data.setId(task.getId());
> data.setName(task.getName());
> data.setDesc(task.getDesc());
> data.setPrio(task.getPrio());
> data.setVersion(task.getVersion());
>
> tasks.add(data);
> }
>
>
> }
> } catch (Exception e) {
> e.printStackTrace();
> }
>
> return tasks;
> }
>
> /**
> *
> * <!-- begin-xdoclet-definition -->
> * @ejb.interface-method view-type="remote"
> * <!-- end-xdoclet-definition -->
> * @generated
> *
> * //TODO: Must provide implementation for bean method stub
> */
> public boolean createTask(TaskVO taskVO, Integer userId){
> boolean bOk = false;
>
> try {
> UserLocalHome home = UserUtil.getLocalHome();
> UserLocal user = home.findByPrimaryKey(userId);
> if(user!=null){
> TaskLocalHome taskHome = TaskUtil.getLocalHome();
> TaskLocal task = taskHome.create(taskVO.getName(),taskVO.getDesc(),taskVO.getPrio());
> task.setUser(user);
>
> bOk = true;
> }
> } catch (Exception e) {
> e.printStackTrace();
> }
>
> return bOk;
> }
>
>
> /* (non-Javadoc)
> * @see javax.ejb.SessionBean#ejbActivate()
> */
> public void ejbActivate() throws EJBException, RemoteException {
> // TODO Auto-generated method stub
>
> }
>
> /* (non-Javadoc)
> * @see javax.ejb.SessionBean#ejbPassivate()
> */
> public void ejbPassivate() throws EJBException, RemoteException {
> // TODO Auto-generated method stub
>
> }
>
> /* (non-Javadoc)
> * @see javax.ejb.SessionBean#ejbRemove()
> */
> public void ejbRemove() throws EJBException, RemoteException {
> // TODO Auto-generated method stub
>
> }
>
> /* (non-Javadoc)
> * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
> */
> public void setSessionContext(SessionContext arg0) throws EJBException,
> RemoteException {
> // TODO Auto-generated method stub
>
> }
>
> /**
> *
> */
> public TaskMgrBean() {
> // TODO Auto-generated constructor stub
> }
> }
>
> ------------------------------------------------------------------------
>
> package de.schleichy.softplan.vo;
>
> import java.io.Serializable;
>
> public class TaskVO implements Serializable {
> /**
> *
> */
> private static final long serialVersionUID = 1L;
>
> private java.lang.Integer id;
>
> private java.lang.String name;
>
> private java.lang.String desc;
>
> private java.lang.String prio;
>
> private java.lang.Integer version;
>
> public TaskVO() {
> }
>
> public java.lang.String getDesc() {
> return desc;
> }
>
> public void setDesc(java.lang.String desc) {
> this.desc = desc;
> }
>
> public java.lang.Integer getId() {
> return id;
> }
>
> public void setId(java.lang.Integer id) {
> this.id = id;
> }
>
> public java.lang.String getName() {
> return name;
> }
>
> public void setName(java.lang.String name) {
> this.name = name;
> }
>
> public java.lang.String getPrio() {
> return prio;
> }
>
> public void setPrio(java.lang.String prio) {
> this.prio = prio;
> }
>
> public java.lang.Integer getVersion() {
> return version;
> }
>
> public void setVersion(java.lang.Integer version) {
> this.version = version;
> }
>
>
>
> }
>
> ------------------------------------------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1"
> xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.1"
> xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen-2.0"
> xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1"
> xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1">
> <sys:environment>
> <sys:moduleId>
> <sys:groupId>default</sys:groupId>
> <sys:artifactId>SoftPlannerEJB</sys:artifactId>
> <sys:version>1.0</sys:version>
> <sys:type>car</sys:type>
> </sys:moduleId>
>
> <sys:dependencies>
> <sys:dependency>
> <sys:groupId>console.dbpool</sys:groupId>
> <sys:artifactId>socke</sys:artifactId>
> </sys:dependency>
> </sys:dependencies>
>
> </sys:environment>
>
> <nam:cmp-connection-factory>
> <nam:resource-link>socke</nam:resource-link>
> </nam:cmp-connection-factory>
>
> <enterprise-beans>
>
> <session>
> <ejb-name>Login</ejb-name>
> <jndi-name>Login</jndi-name>
> <ejb-ref>
> <ref-name>ejb/UserLocal</ref-name>
> <ejb-link>User</ejb-link>
> </ejb-ref>
>
> </session>
>
> <session>
> <ejb-name>TaskMgr</ejb-name>
> <jndi-name>TaskMgr</jndi-name>
> <ejb-ref>
> <ref-name>ejb/User</ref-name>
> <ejb-link>User</ejb-link>
> </ejb-ref>
> <ejb-ref>
> <ref-name>ejb/Task</ref-name>
> <ejb-link>Task</ejb-link>
> </ejb-ref>
>
> </session>
>
>
> <entity>
> <ejb-name>User</ejb-name>
> <table-name>USER</table-name>
> <cmp-field-mapping>
> <cmp-field-name>id</cmp-field-name>
> <table-column>ID</table-column>
> </cmp-field-mapping>
> <cmp-field-mapping>
> <cmp-field-name>login</cmp-field-name>
> <table-column>LOGIN</table-column>
> </cmp-field-mapping>
> <cmp-field-mapping>
> <cmp-field-name>password</cmp-field-name>
> <table-column>PASSWORD</table-column>
> </cmp-field-mapping>
> <cmp-field-mapping>
> <cmp-field-name>name</cmp-field-name>
> <table-column>NAME</table-column>
> </cmp-field-mapping>
> <cmp-field-mapping>
> <cmp-field-name>preName</cmp-field-name>
> <table-column>PRE_NAME</table-column>
> </cmp-field-mapping>
> <cmp-field-mapping>
> <cmp-field-name>email</cmp-field-name>
> <table-column>EMAIl</table-column>
> </cmp-field-mapping>
> <cmp-field-mapping>
> <cmp-field-name>phone</cmp-field-name>
> <table-column>PHONE</table-column>
> </cmp-field-mapping>
> <cmp-field-mapping>
> <cmp-field-name>version</cmp-field-name>
> <table-column>VERSION</table-column>
> </cmp-field-mapping>
> <key-generator>
> <sql-generator>
> <sql>select USER_SEQ.NEXTVAL from dual</sql>
> <return-type>java.lang.Integer</return-type>
> </sql-generator>
> </key-generator>
> </entity>
>
> <entity>
> <ejb-name>Task</ejb-name>
> <table-name>TASK</table-name>
> <cmp-field-mapping>
> <cmp-field-name>id</cmp-field-name>
> <table-column>ID</table-column>
> </cmp-field-mapping>
> <cmp-field-mapping>
> <cmp-field-name>name</cmp-field-name>
> <table-column>NAME</table-column>
> </cmp-field-mapping>
> <cmp-field-mapping>
> <cmp-field-name>desc</cmp-field-name>
> <table-column>DESC</table-column>
> </cmp-field-mapping>
> <cmp-field-mapping>
> <cmp-field-name>prio</cmp-field-name>
> <table-column>PRIO</table-column>
> </cmp-field-mapping>
> <cmp-field-mapping>
> <cmp-field-name>user</cmp-field-name>
> <table-column>USER_ID</table-column>
> </cmp-field-mapping>
> <cmp-field-mapping>
> <cmp-field-name>version</cmp-field-name>
> <table-column>VERSION</table-column>
> </cmp-field-mapping>
> <key-generator>
> <sql-generator>
> <sql>select TASK_SEQ.NEXTVAL from dual</sql>
> <return-type>java.lang.Integer</return-type>
> </sql-generator>
> </key-generator>
> </entity>
>
>
> </enterprise-beans>
> <relationships>
> <ejb-relation>
> <ejb-relation-name>Task-User</ejb-relation-name>
> <ejb-relationship-role>
> <ejb-relationship-role-name>Task-to-User</ejb-relationship-role-name>
> <relationship-role-source>
> <ejb-name>Task</ejb-name>
> </relationship-role-source>
> <cmr-field>
> <cmr-field-name>user</cmr-field-name>
> </cmr-field>
> <foreign-key-column-on-source/>
> <role-mapping>
> <cmr-field-mapping>
> <key-column>ID</key-column>
> <foreign-key-column>USER_ID</foreign-key-column>
> </cmr-field-mapping>
> </role-mapping>
> </ejb-relationship-role>
> </ejb-relation>
>
> </relationships>
>
> </openejb-jar>
> ------------------------------------------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <ejb-jar id="ejb-jar_1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" version="2.1">
>
> <description><![CDATA[SoftPlannerEJB generated by eclipse wtp xdoclet extension.]]></description>
> <display-name>SoftPlannerEJB</display-name>
>
> <enterprise-beans>
>
> <!-- Session Beans -->
> <session id="Session_Login">
> <description><![CDATA[An EJB named Login]]></description>
> <display-name>Login</display-name>
>
> <ejb-name>Login</ejb-name>
>
> <home>de.schleichy.softplan.ejb.session.LoginHome</home>
> <remote>de.schleichy.softplan.ejb.session.Login</remote>
> <local-home>de.schleichy.softplan.ejb.session.LoginLocalHome</local-home>
> <local>de.schleichy.softplan.ejb.session.LoginLocal</local>
> <ejb-class>de.schleichy.softplan.ejb.session.LoginSession</ejb-class>
> <session-type>Stateless</session-type>
> <transaction-type>Container</transaction-type>
>
> <ejb-ref id="EJBRef_1">
> <ejb-ref-name>ejb/User</ejb-ref-name>
> <ejb-ref-type>Entity</ejb-ref-type>
> <home>de.schleichy.softplan.ejb.entity.UserHome</home>
> <remote>de.schleichy.softplan.ejb.entity.User</remote>
> <ejb-link>User</ejb-link>
> </ejb-ref>
>
> </session>
>
> <session id="Session_TaskMgr">
> <description><![CDATA[An EJB named TaskMgr]]></description>
> <display-name>TaskMgr</display-name>
>
> <ejb-name>TaskMgr</ejb-name>
>
> <home>de.schleichy.softplan.ejb.session.TaskMgrHome</home>
> <remote>de.schleichy.softplan.ejb.session.TaskMgr</remote>
> <local-home>de.schleichy.softplan.ejb.session.TaskMgrLocalHome</local-home>
> <local>de.schleichy.softplan.ejb.session.TaskMgrLocal</local>
> <ejb-class>de.schleichy.softplan.ejb.session.TaskMgrSession</ejb-class>
> <session-type>Stateless</session-type>
> <transaction-type>Container</transaction-type>
>
> <ejb-local-ref id="EJBLocalRef_1">
> <ejb-ref-name>ejb/UserLocal</ejb-ref-name>
> <ejb-ref-type>Entity</ejb-ref-type>
> <local-home>de.schleichy.softplan.ejb.entity.UserLocalHome</local-home>
> <local>de.schleichy.softplan.ejb.entity.UserLocal</local>
> <ejb-link>User</ejb-link>
> </ejb-local-ref>
> <ejb-local-ref id="EJBLocalRef_2">
> <ejb-ref-name>ejb/TaskLocal</ejb-ref-name>
> <ejb-ref-type>Entity</ejb-ref-type>
> <local-home>de.schleichy.softplan.ejb.entity.TaskLocalHome</local-home>
> <local>de.schleichy.softplan.ejb.entity.TaskLocal</local>
> <ejb-link>Task</ejb-link>
> </ejb-local-ref>
>
> </session>
>
> <!--
> To add session beans that you have deployment descriptor info for, add
> a file to your XDoclet merge directory called session-beans.xml that contains
> the <session></session> markup for those beans.
> -->
>
> <!-- Entity Beans -->
> <entity id="ContainerManagedEntity_User">
> <description><![CDATA[<!-- begin-xdoclet-definition -->]]></description>
>
> <ejb-name>User</ejb-name>
>
> <home>de.schleichy.softplan.ejb.entity.UserHome</home>
> <remote>de.schleichy.softplan.ejb.entity.User</remote>
> <local-home>de.schleichy.softplan.ejb.entity.UserLocalHome</local-home>
> <local>de.schleichy.softplan.ejb.entity.UserLocal</local>
>
> <ejb-class>de.schleichy.softplan.ejb.entity.UserCMP</ejb-class>
> <persistence-type>Container</persistence-type>
> <prim-key-class>java.lang.Integer</prim-key-class>
> <reentrant>false</reentrant>
> <cmp-version>2.x</cmp-version>
> <abstract-schema-name>UserSCHEMA</abstract-schema-name>
> <cmp-field id="CMPAttribute_1">
> <description><![CDATA[<!-- begin-user-doc --> CMP Field id Returns the id]]></description>
> <field-name>id</field-name>
> </cmp-field>
> <cmp-field id="CMPAttribute_2">
> <description><![CDATA[<!-- begin-user-doc --> CMP Field login Returns the login]]></description>
> <field-name>login</field-name>
> </cmp-field>
> <cmp-field id="CMPAttribute_3">
> <description><![CDATA[<!-- begin-user-doc --> CMP Field password Returns the password]]></description>
> <field-name>password</field-name>
> </cmp-field>
> <cmp-field id="CMPAttribute_4">
> <description><![CDATA[<!-- begin-user-doc --> CMP Field name Returns the name]]></description>
> <field-name>name</field-name>
> </cmp-field>
> <cmp-field id="CMPAttribute_5">
> <description><![CDATA[<!-- begin-user-doc --> CMP Field pre_name Returns the pre_name]]></description>
> <field-name>preName</field-name>
> </cmp-field>
> <cmp-field id="CMPAttribute_6">
> <description><![CDATA[<!-- begin-user-doc --> CMP Field email Returns the email]]></description>
> <field-name>email</field-name>
> </cmp-field>
> <cmp-field id="CMPAttribute_7">
> <description><![CDATA[<!-- begin-user-doc --> CMP Field phone Returns the phone]]></description>
> <field-name>phone</field-name>
> </cmp-field>
> <cmp-field id="CMPAttribute_8">
> <description><![CDATA[<!-- begin-user-doc --> CMP Field version Returns the version]]></description>
> <field-name>version</field-name>
> </cmp-field>
> <primkey-field>id</primkey-field>
>
> <query>
> <query-method>
> <method-name>findAll</method-name>
> <method-params>
> </method-params>
> </query-method>
> <ejb-ql><![CDATA[SELECT OBJECT(a) FROM UserSCHEMA as a]]></ejb-ql>
> </query>
> <query>
> <query-method>
> <method-name>findByName</method-name>
> <method-params>
> <method-param>java.lang.String</method-param>
> </method-params>
> </query-method>
> <ejb-ql><![CDATA[SELECT OBJECT(a) FROM UserSCHEMA as a WHERE a.login = ?1]]></ejb-ql>
> </query>
> <!-- Write a file named ejb-finders-UserBean.xml if you want to define extra finders. -->
>
> </entity>
>
> <entity id="ContainerManagedEntity_Task">
> <description><![CDATA[<!-- begin-xdoclet-definition -->]]></description>
>
> <ejb-name>Task</ejb-name>
>
> <home>de.schleichy.softplan.ejb.entity.TaskHome</home>
> <remote>de.schleichy.softplan.ejb.entity.Task</remote>
> <local-home>de.schleichy.softplan.ejb.entity.TaskLocalHome</local-home>
> <local>de.schleichy.softplan.ejb.entity.TaskLocal</local>
>
> <ejb-class>de.schleichy.softplan.ejb.entity.TaskCMP</ejb-class>
> <persistence-type>Container</persistence-type>
> <prim-key-class>java.lang.Integer</prim-key-class>
> <reentrant>false</reentrant>
> <cmp-version>2.x</cmp-version>
> <abstract-schema-name>TaskSCHEMA</abstract-schema-name>
> <cmp-field id="CMPAttribute_9">
> <description><![CDATA[<!-- begin-user-doc --> CMP Field id Returns the id]]></description>
> <field-name>id</field-name>
> </cmp-field>
> <cmp-field id="CMPAttribute_10">
> <description><![CDATA[<!-- begin-user-doc --> CMP Field name Returns the name]]></description>
> <field-name>name</field-name>
> </cmp-field>
> <cmp-field id="CMPAttribute_11">
> <description><![CDATA[<!-- begin-user-doc --> CMP Field desc Returns the desc]]></description>
> <field-name>desc</field-name>
> </cmp-field>
> <cmp-field id="CMPAttribute_12">
> <description><![CDATA[<!-- begin-user-doc --> CMP Field prio Returns the prio]]></description>
> <field-name>prio</field-name>
> </cmp-field>
> <cmp-field id="CMPAttribute_13">
> <description><![CDATA[<!-- begin-user-doc --> CMP Field user Returns the user]]></description>
> <field-name>user</field-name>
> </cmp-field>
> <cmp-field id="CMPAttribute_14">
> <description><![CDATA[<!-- begin-user-doc --> CMP Field version Returns the version]]></description>
> <field-name>version</field-name>
> </cmp-field>
> <primkey-field>id</primkey-field>
>
> <query>
> <query-method>
> <method-name>findAll</method-name>
> <method-params>
> </method-params>
> </query-method>
> <ejb-ql><![CDATA[SELECT OBJECT(a) FROM TaskSCHEMA as a]]></ejb-ql>
> </query>
> <!-- Write a file named ejb-finders-TaskBean.xml if you want to define extra finders. -->
>
> </entity>
>
> <!--
> To add entity beans that you have deployment descriptor info for, add
> a file to your XDoclet merge directory called entity-beans.xml that contains
> the <entity></entity> markup for those beans.
> -->
>
> <!-- Message Driven Beans -->
> <!--
> To add message driven beans that you have deployment descriptor info for, add
> a file to your XDoclet merge directory called message-driven-beans.xml that contains
> the <message-driven></message-driven> markup for those beans.
> -->
>
> </enterprise-beans>
>
> <!-- Relationships -->
> <relationships id="Relationships_1">
> <ejb-relation id="EJBRelation_1">
> <ejb-relation-name>Task-User</ejb-relation-name>
>
> <ejb-relationship-role id="EJBRelationshipRole_1">
> <ejb-relationship-role-name>Task-to-User</ejb-relationship-role-name>
> <multiplicity>Many</multiplicity>
> <relationship-role-source id="RoleSource_1">
> <ejb-name>Task</ejb-name>
> </relationship-role-source>
> <cmr-field id="CMRField_1">
> <cmr-field-name>user</cmr-field-name>
> </cmr-field>
> </ejb-relationship-role>
>
> <ejb-relationship-role id="EJBRelationshipRole_2">
> <ejb-relationship-role-name>User-to-Task</ejb-relationship-role-name>
> <multiplicity>One</multiplicity>
> <relationship-role-source id="RoleSource_2">
> <ejb-name>User</ejb-name>
> </relationship-role-source>
> <cmr-field id="CMRField_2">
> <cmr-field-name>tasks</cmr-field-name>
> <cmr-field-type>java.util.Collection</cmr-field-type>
> </cmr-field>
> </ejb-relationship-role>
>
> </ejb-relation>
> <!--
> To add relationships for beans not managed by XDoclet, add
> a file to your XDoclet merge directory called relationships.xml that contains
> the <ejb-relation></ejb-relation> markups for those beans.
> -->
> </relationships>
>
> <!-- Assembly Descriptor -->
> <!--
> To specify your own assembly descriptor info here, add a file to your
> XDoclet merge directory called assembly-descriptor.xml that contains
> the <assembly-descriptor></assembly-descriptor> markup.
> -->
>
> <assembly-descriptor id="AssemblyDescriptor_1">
> <!--
> To specify additional security-role elements, add a file in the merge
> directory called ejb-security-roles.xml that contains them.
> -->
>
> <!-- method permissions -->
> <!--
> To specify additional method-permission elements, add a file in the merge
> directory called ejb-method-permissions.ent that contains them.
> -->
>
> <!-- transactions -->
> <!--
> To specify additional container-transaction elements, add a file in the merge
> directory called ejb-container-transactions.ent that contains them.
> -->
> <container-transaction id="MethodTransaction_1">
> <method id="MethodElement_1">
> <ejb-name>Login</ejb-name>
> <method-intf>Remote</method-intf>
> <method-name>login</method-name>
> <method-params>
> <method-param>java.lang.String</method-param>
> <method-param>java.lang.String</method-param>
> </method-params>
> </method>
> <trans-attribute>RequiresNew</trans-attribute>
> </container-transaction>
> <container-transaction id="MethodTransaction_2">
> <method id="MethodElement_2">
> <ejb-name>TaskMgr</ejb-name>
> <method-intf>Remote</method-intf>
> <method-name>getTasks</method-name>
> <method-params>
> <method-param>java.lang.Integer</method-param>
> </method-params>
> </method>
> <trans-attribute>RequiresNew</trans-attribute>
> </container-transaction>
>
> <!-- finder transactions -->
>
> <!-- message destinations -->
> <!--
> To specify additional message-destination elements, add a file in the merge
> directory called ejb-message-destinations.ent that contains them.
> -->
>
> <!-- exclude list -->
> <!--
> To specify an exclude-list element, add a file in the merge directory
> called ejb-exclude-list.xml that contains it.
> -->
> </assembly-descriptor>
>
> </ejb-jar>
>
> ------------------------------------------------------------------------
>
> package de.schleichy.softplan.web.beans;
>
> import java.util.List;
> import java.util.Vector;
>
> import javax.faces.component.UIData;
>
> import de.schleichy.softplan.ejb.session.TaskMgr;
> import de.schleichy.softplan.ejb.session.TaskMgrHome;
> import de.schleichy.softplan.ejb.session.TaskMgrUtil;
> import de.schleichy.softplan.vo.TaskVO;
>
> public class TaskBean extends BaseBean {
>
> protected UIData dataTable;
>
> protected List tasks = new Vector();
>
> protected TaskVO currenttask = new TaskVO();
>
> public TaskVO getCurrenttask() {
> return currenttask;
> }
>
> public void setCurrenttask(TaskVO currenttask) {
> this.currenttask = currenttask;
> }
>
> public List getTasks() {
>
> tasks.clear();
> try {
> Integer userId = getVisitBean().getLoginBean().getId();
> TaskMgrHome taskMgrHome = TaskMgrUtil.getHome();
> TaskMgr taskMgr = taskMgrHome.create();
> List beanTasks = taskMgr.getTasks(userId);
> tasks.addAll(beanTasks);
>
> } catch (Exception e) {
> e.printStackTrace();
> }
>
> return tasks;
> }
>
> public UIData getDataTable() {
> return dataTable;
> }
>
> public void setDataTable(UIData data) {
> this.dataTable = data;
> }
>
> public String create(){
> String retval = Constants.FAILURE;
>
> try {
> TaskMgrHome taskMgrHome = TaskMgrUtil.getHome();
> TaskMgr taskMgr = taskMgrHome.create();
> if(taskMgr.createTask(currenttask, getVisitBean().getLoginBean().getId())){
> retval = Constants.SUCCESS;
> }
> } catch (Exception e) {
> e.printStackTrace();
> }
> return retval;
> }
>
>
> }
>
|