poubelle2011
Messages postés6Date d'inscriptionmardi 25 février 2014StatutMembreDernière intervention11 mars 2021
-
Modifié par KX le 10/12/2015 à 19:36
Bonjour,
salut
j'un probleme dans mon application jee; j'ai une classe compte et deux classes compteBacaire et comptePostal je veut qu' ils heritent la classe compte mais jai crée une entite compte et deux autres entites compte bancaire et comptePostal mais la classe Comptecontroller generé automatiquement et compteFacade de meme et j'ai ne pas peu configurer les classes CompteBancaireController et comptePostalController pour creer des comptes aproprie et voila la claase compte{
@Entity
@Table(name = "compte")
@XmlRootElement
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE_CPTE", discriminatorType = DiscriminatorType.STRING, length = 8)
public abstract class Compte implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "ref")
private Integer ref;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 245)
@Column(name = "label")
private String label;
public Compte() {
}
public Compte(Integer ref) {
this.ref = ref;
}
public Compte(Integer ref, String label, boolean deleted) {
this.ref = ref;
this.label = label;
this.deleted = deleted;
}
public Integer getRef() {
return ref;
}
public void setRef(Integer ref) {
this.ref = ref;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
@Override
public int hashCode() {
int hash = 0;
hash += (ref != null ? ref.hashCode() : 0);
return hash;
}
@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 Compte)) {
return false;
}
Compte other = (Compte) object;
if ((this.ref == null && other.ref != null) || (this.ref != null && !this.ref.equals(other.ref))) {
return false;
}
return true;
}
@Override
public String toString() {
return "entity.Compte[ ref=" + ref + " ]";
}
}
la classe compteController{
@Named("compteController")
@SessionScoped
public class CompteController implements Serializable {
private Compte current;
private DataModel items = null;
@EJB
private facade.CompteFacade ejbFacade;
private PaginationHelper pagination;
private int selectedItemIndex;
public CompteController() {
}
public Compte getSelected() {
if (current == null) {
current = new Compte();
selectedItemIndex = -1;
}
return current;
}
private CompteFacade getFacade() {
return ejbFacade;
}
public PaginationHelper getPagination() {
if (pagination == null) {
pagination = new PaginationHelper(10) {
@Override
public int getItemsCount() {
return getFacade().count();
}
@Override
public DataModel createPageDataModel() {
return new ListDataModel(getFacade().findRange(new int[]{getPageFirstItem(), getPageFirstItem() + getPageSize()}));
}
};
}
return pagination;
}
public String prepareList() {
recreateModel();
return "List";
}
public String prepareView() {
current = (Compte) getItems().getRowData();
selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
return "View";
}
public String prepareCreate() {
current = new Compte();
selectedItemIndex = -1;
return "Create";
}
public String create() {
try {
getFacade().create(current);
JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/messages").getString("CompteCreated"));
return prepareCreate();
} catch (Exception e) {
JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/messages").getString("PersistenceErrorOccured"));
return null;
}
}
ect...
merci de guider comment configurer les deux comptes qui heritent la classe Compte merci