Ejb-enchainement d'un projet de j2ee

1023 mots 5 pages
EJB:traitement des classes
@Entity
public class Account implements Serializable{

private String name; private int amount; private Collection coOwner = new ArrayList();

public Account(String n, int s) { super(); this.name = n; this.amount = s; this.setCoOwner(new Vector());
}

public Account(){ super(); }

@Id public String getName(){ return this.name;
}

public void setName(String n){ this.name = n;
}

public int getAmount(){ return this.amount;
}

public void addCoOwner(CoOwner ass){ this.coOwner.add(ass); }

public void setAmount(int amnt){ this.amount = amnt;
}

public void setCoOwner(Collection coOwner) { this.coOwner = coOwner;
}

@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.REMOVE}, fetch=FetchType.EAGER) public Collection getCoOwner() { return coOwner;
}
}

@Stateless public class AccountSessionBean implements AccountSessionBeanRemote {

@PersistenceContext private EntityManager em;

/** * Default constructor. */ public AccountSessionBean() { // TODO Auto-generated constructor stub } public void createAccount(String name, int amnt){
Account account = new Account(name,amnt); em.persist(account); }

public int getBalance(String name){
Account account = em.find(Account.class, name); return account.getAmount();
}

public void setBalance(String name, int amnt){
Account account = em.find(Account.class, name); account.setAmount(amnt); em.merge(account);
}

public ArrayList listAccount(){
List list = em.createQuery("SELECT p FROM Account p").getResultList();
ArrayList al = new ArrayList(); for(Account a: list){ al.add(a); } return al;
}

public void addCoOwner(String nameOwner, CoOwner assos){ em.persist(assos); Account account = em.find(Account.class, nameOwner); account.addCoOwner(assos); em.merge(account);
}

public ArrayList getCoOwner(String nameOwner){
Account account = em.find(Account.class, nameOwner);
Collection associes =

en relation

  • Eco gestion tise
    2436 mots | 10 pages
  • Projet bts muc
    3314 mots | 14 pages
  • Fiche projet bts nrc
    730 mots | 3 pages
  • ProjetJavaM1 14 15 Enonc
    609 mots | 3 pages
  • Bpjeps apt projet apn
    4725 mots | 19 pages
  • Projet bts ag
    1961 mots | 8 pages
  • Projet de com dev1 2eme année cned
    778 mots | 4 pages
  • projet bpjeps apt
    5142 mots | 21 pages
  • Projets cci oujda
    391 mots | 2 pages
  • Flyff
    6971 mots | 28 pages
  • Gestion, t3
    2896 mots | 12 pages
  • Projet bts ag
    2936 mots | 12 pages
  • Cas de négociation Distributoor
    880 mots | 4 pages
  • Projet uc4 bpjeps
    1071 mots | 5 pages
  • Projet bts ag
    3423 mots | 14 pages