Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences


Referenced by
Articles
CreateManager_it
LeftMenu




JSPWiki v2.2.33

[RSS]


Hide Menu

CreateDAO_it


Difference between version 7 and version 6:

At line 46 changed 1 line.
Generate your getters and setters using your favorite IDE:
Genera i tuoi getter e setter usando il tuoi IDE preferito:
At line 48 changed 1 line.
Right-click -> Source -> Generate Getters and Setters
Pulsante Destro -> Source -> Generate Getters and Setters
At line 286 changed 1 line.
Prima di tutto, crea un'interfaccia PersonDao.java nella directory {{src/dao/**/dao}} e specifica i metodi CRUD basilari per tutte le classi di implementazione.
Prima di tutto, crea un'interfaccia PersonDao.java nella directory {{src/dao/**/dao}} e specifica i metodi CRUD principali per tutte le classi di implementazione.
At line 301 changed 1 line.
Notice in the class above there are no exceptions on the method signatures. This is due to the power of [Spring|http://www.springframework.org] and how it wraps Exceptions with RuntimeExceptions. At this point, you should be able to compile all the source in {{src/dao}} and {{test/dao}} using __ant compile-dao__. However, if you try to run __ant test-dao -Dtestcase=PersonDao__, you will get an error: <span style="color: red">No bean named 'personDao' is defined</span>. This is an error message from Spring - indicating that you need to specify a bean named ''personDao'' in {{applicationContext-hibernate.xml}}. Before you do that, you need to create the PersonDao implementation class.
Nota bene che nella classe qui sopra non ci sono eccezioni nelle firme dei metodi. Ciò è dovuto alla potenza di [Spring|http://www.springframework.org] e a come maschera le Exception con RuntimeException. A questo punto, dovresti essere in grado di compilare tutto il sorgente in {{src/dao}} e {{test/dao}} usando __ant compile-dao__. Tuttavia, se provi ad eseguire __ant test-dao -Dtestcase=PersonDao__, otterrai un errore: <span style="color: red">No bean named 'personDao' is defined</span>. Questo è un messaggio di errore provenienta da Spring - il quale indica che devi specificare un bean denominato ''personDao'' in {{applicationContext-hibernate.xml}}. Prima di farlo però, devi creare la classe di implementazione di PersonDao.
At line 303 changed 1 line.
;:''The ant task for running dao tests is called __test-dao__. If you pass in a testcase parameter (using __-Dtestcase=name__), it will look for {{**/*${testcase}*}} - allowing us to pass in Person, PersonDao, or PersonDaoTest - all of which will execute the PersonDaoTest class.''
;:''Il task ant per eseguire i test sui dao si chiama __test-dao__. Se passi un parametro testcase (using __-Dtestcase=name__), cercherà {{**/*${testcase}*}} - permettendoci di passare su Person, PersonDao, o PersonDaoTest - i quali eseguiranno tutti la classe PersonDaoTest.''
At line 305 changed 1 line.
Let's start by creating a PersonDaoHibernate class that implements the methods in PersonDao and uses Hibernate to get/save/delete the Person object. To do this, create a new class in {{src/dao/**/dao/hibernate}} and name it {{PersonDaoHibernate.java}}. It should extend [BaseDaoHibernate|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/dao/BaseDAOHibernate.java.html] and implement PersonDao. ''Javadocs eliminated for brevity.''
Iniziamo con il creare una classe PersonDaoHibernate che implementi i metodi in PersonDao e usi Hibernate per ottenere/registrare/eliminare l'oggetto Person. Per far questo, crea una nuova classe in {{src/dao/**/dao/hibernate}} e chiamala {{PersonDaoHibernate.java}}. Dovrebbe estendere [BaseDaoHibernate|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/dao/BaseDAOHibernate.java.html] ed implementare PersonDao. ''Javadoc eliminati per brevità.''
At line 338 changed 1 line.
Now, if you try to run __ant test-dao -Dtestcase=PersonDao__, you will get the same error. We need to configure Spring so it knows that PersonDaoHibernate is the implementation of PersonDao, and you also need to tell it about the Person object.
Ora, se provi ad eseguire __ant test-dao -Dtestcase=PersonDao__, otterrai lo stesso errore. Dobbiamo configurare Spring in modo che sappia che PersonDaoHibernate è l'implementazione di PersonDao, e dobbiamo dirgli anche qualcosa sull'oggetto Person.
At line 340 changed 1 line.
!!Configure Spring for the Person object and PersonDao [#5]
!!Configurare Spring per l'oggetto Person e il PersonDao [#5]
At line 342 changed 1 line.
First, you need to tell Spring where the Hibernate mapping file is located. To do this, open {{src/dao/**/dao/hibernate/applicationContext-hibernate.xml}} and add {{"Person.hbm.xml"}} to the following code block.
Innanzitutto, devi dire a Springdove si trova il file di mapping di Hibernate. Per farlo, apri {{src/dao/**/dao/hibernate/applicationContext-hibernate.xml}} ed aggiungi {{"Person.hbm.xml"}} al blocco di codice seguente.
At line 355 changed 1 line.
Now you need to add some XML to this file to bind PersonDaoHibernate to PersonDao. To do this, add the following at the bottom of the file:
Ora devi aggiungere un po' di XML a questo file per collegare PersonDaoHibernate a PersonDao. Per far questo, aggiungi quanto segue alla fine del file:
At line 359 changed 1 line.
<!-- PersonDao: Hibernate implementation -->
<!-- PersonDao: implementazione Hibernate -->

Back to CreateDAO_it, or to the Page History.