Ciao a tutti, ecco che mi presento con un nuovo problema :P.
Ho configurato tutti i file di Hibernate e ho iniziato a creare la mia struttura. Prima di tutto mi sono creato la mia cara Home.
Codice PHP:
//Sarebbe la classe UtentiHome
private static final SessionFactory sessionFactory;
protected Log logger = LogFactory.getLog(this.getClass());
static {
try {
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
} catch (Throwable ex) {
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
/**
*
* @param utente
* Metodo per creare un utente;
*/
public void persist(Utenti utente) {
logger.debug("Start persist utente");
try {
sessionFactory.getCurrentSession().persist(utente);
logger.debug("End persist utente");
}
catch (RuntimeException error) {
logger.error("persist failed", error);
throw error;
}
}
e poi mi sono creato la mia classe Business che estende Home.
Codice PHP:
public UtentiMapping login(String nickname, String password){
logger.debug("Start login");
Utenti utente = new Utenti();
UtentiMapping u = new UtentiMapping();
UtentiHome dao = new UtentiHome();
Session session = UtentiHome.getSessionFactory().openSession();
Transaction tx = null;
try{
tx = session.beginTransaction();
utente = dao.login(nickname, password);
//QUi dovrei fare il fill tra UtentiMapping e Utenti
tx.commit();
logger.debug("End login");
}
catch(RuntimeException error){
logger.error("Error login: ",error);
}
return u;
}
Soltanto che mi dice :
UtentiBusiness non può ereditare il metodo login. Se lo trasformo in Utenti piuttosto che UtentiMapping funziona. SOltanto che non vorrei farmi tornare l'oggetto Hibernate, ma un oggetto che mi sono creato io e mapparlo con ciò che mi faccio tornare dal DB