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 5 and version 4:

At line 153 changed 1 line.
In questo esempio, l'unico motivo per aggiungere l'attributo ''column'è perché il nome della colonna è diverso dal nome della proprietà. Se sono uguali, non devi specificare l'attributo ''column'. Vedi la reference [@hibernate.property|http://xdoclet.sourceforge.net/tags/hibernate-tags.html#@hibernate.property%20(0..1)] degli altri attributi che puoi specificare per questo tag.
In questo esempio, l'unico motivo per aggiungere l'attributo ''column'' è perché il nome della colonna è diverso dal nome della proprietà. Se sono uguali, non devi specificare l'attributo ''column''. Vedi la documentazione [@hibernate.property|http://xdoclet.sourceforge.net/tags/hibernate-tags.html#@hibernate.property%20(0..1)] per gli altri attributi che puoi specificare per questo tag.
At line 168 changed 1 line.
%%note <a name="appgen"></a>__NOTA:__ Le versioni di AppFuse dalla 1.6.1 in su contengono uno strumento, [AppGen]m che può essere usato per generare tutte le classi per il resto di questi tutorial. Tuttavia, è meglio che tu prosegua questi tutorial prima di utilizzare questo strumento - così poi saprai che codice ti sta generando.%%
%%note <a name="appgen"></a>__NOTA:__ Le versioni di AppFuse dalla 1.6.1 in su contengono lo strumento [AppGen] che può essere usato per generare tutte le classi per il resto di questi tutorial. Tuttavia, è meglio che tu prosegua questi tutorial prima di utilizzare questo strumento - così poi saprai che codice ti sta generando.%%
At line 170 changed 1 line.
Now you'll create a DaoTest to test that your DAO works. "Wait a minute," you say, "I haven't created a DAO!" You are correct. However, I've found that [Test-Driven Development|http://www.artima.com/intv/testdriven.html] breeds higher quality software. For years, I thought __write your test before your class__ was hogwash. It just seemed stupid. Then I tried it and I found that it works great. The only reason I do all this test-driven stuff now is because I've found it rapidly speeds up the process of software development.
Ora c'è da creare un DaoTest per verificare che il tuo DAO funzioni. "Aspetta un momento," mi dirai, "Io non ho creato un DAO!" Ed hai ragione. Tuttavia, ho scoperto che il [Test-Driven Development|http://www.artima.com/intv/testdriven.html] permette di tirar su codice di miglior qualità. Per anni ho pensato che lo __scrivere i test prima delle classi__ fosse una sonora boiata. É che mi sembrava stupido e basta. Poi ho provato a farlo ed ho scoperto che invece funziona alla grande. L'unico motivo per cui ora faccio tutto questa roba test-driven è perché ho scoperto che accelera in tempi brevi il processo di sviluppo software.
At line 172 changed 1 line.
To start, create a {{PersonDaoTest.java}} class in the {{test/dao/**/dao}} directory. This class should extend [BaseDaoTestCase|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/dao/BaseDaoTestCase.java.html], a subclass of Spring's [AbstractTransactionalDataSourceSpringContextTests|http://www.springframework.org/docs/api/org/springframework/test/AbstractTransactionalDataSourceSpringContextTests.html] which already exists in this package. This parent class is used to load [Spring's|http://www.springframework.org] ApplicationContext (since Spring binds the layers together), and for (optionally) loading a .properties file (ResourceBundle) that has the same name as your {{*Test.class}}. In this example, if you put a {{PersonDaoTest.properties}} file in the same directory as {{PersonDaoTest.java}}, this file's properties will be available via an "rb" variable.
Per iniziare, crea una classe {{PersonDaoTest.java}} nella directory {{test/dao/**/dao}}. Questa classe deve estendere [BaseDaoTestCase|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/dao/BaseDaoTestCase.java.html], una sotto classe del [AbstractTransactionalDataSourceSpringContextTests|http://www.springframework.org/docs/api/org/springframework/test/AbstractTransactionalDataSourceSpringContextTests.html] di Spring che esiste già in questo package. Questa classe parent viene usata per caricare l'ApplicationContext di [Spring|http://www.springframework.org] (in quanto Spring collega i vari layer insieme), e per (opzionalmente) caricare un file .properties (ResourceBundle) con lo stesso nome della tua {{*Test.class}}. In questo esempio, se metti un file {{PersonDaoTest.properties}} nella stessa directory di {{PersonDaoTest.java}}, le properties in questo file saranno rese disponibili tramite la variabile "rb".
At line 365 changed 2 lines.
!!Run the DaoTest [#6]
Save all your edited files and try running __ant test-dao -Dtestcase=PersonDao__ one more time.
!!Eseguire il DaoTest [#6]
Registra tutti i tuoi file modificati e prova ad eseguire __ant test-dao -Dtestcase=PersonDao__ un'altra volta.

Back to CreateDAO_it, or to the Page History.