Id | |Name | |
---|---|
| |
| #{department.name} | |
Name: | |
| |
|
Rate the product | || | ||
Review Title | |
|
|
|
select o from Departments o
*/
| public List");
| Sb.append("
| ");
| Sb.append("
select o from Departments o
*/
| public List| | | | | |||
| | | | | | | | | | ||
| | | | | |||
| | | | | | | | | | ||
| | | | |
| | | | | |||
| | | | | |||
| | | | | |||
| | | | | |||
| | | | | |||
| | | | | |||
| | | | | |||
| | | | | |||
| | | | | |||
| | | | |
| | | | |
true
if and only if the argument is not null and is a NewEntityBean object that
| * has the same id field values as this object.
| * @param object the reference object with which to compare
| * @return true
if this object is the same as the argument;
| * false
otherwise.
| */
| @Override
| public boolean equals(Object object) {
| // TODO: Warning - this method won't work in the case the id fields are not set
| if (!(object instanceof NewEntityBean)) {
| return false;
| }
| NewEntityBean other = (NewEntityBean)object;
| if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) return false;
| return true;
| }
|
| /**
| * Returns a string representation of the object. This implementation constructs
| * that representation based on the id fields.
| * @return a string representation of the object.
| */
| @Override
| public String toString() {
| return "myEJBs.NewEntityBean[id=" + id + "]";
| }
|
| }
|
| a stateless session bean:
| /*
| * NewSessionBean.java
| *
| * Created on 7 agosto 2007, 14.31
| *
| * To change this template, choose Tools | Template Manager
| * and open the template in the editor.
| */
|
| package myEJBs;
|
| import javax.ejb.Stateless;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
|
| /**
| *
| * @author IG17540
| */
| @Stateless
| public class NewSessionBean implements NewSessionRemote, NewSessionLocal {
|
| @PersistenceContext
| private EntityManager em;
|
| /** Creates a new instance of NewSessionBean */
| public NewSessionBean() {
| }
|
| public Integer calcola(Integer a) {
| //TODO implement calcola
| return null;
| }
|
| public void persist() {
| NewEntityBean eb = new NewEntityBean();
| em.persist(eb);
| }
|
| }
|
|
|
| a jsp page:
| <%
| InitialContext ctx = new InitialContext();
| NewSessionLocal eb = (NewSessionLocal) ctx.lookup("EnterpriseApplication1/NewSessionBean/local");
| out.write(eb.calcola(new Integer(4)).toString());
|
|
| eb.persist();
| %>
|
the persistence.xml:
EnterpriseApplication1/Datasource
|