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
Articles_pt
LeftMenu




JSPWiki v2.2.33

[RSS]


Hide Menu

CreateDAO_es


Difference between version 27 and version 7:

At line 1 changed 1 line.
__Parte I:__ [Creación de nuevos DAOs y Objetos en AppFuse|CreateDAO] - Esto es un HowTo de como crear nuevos Objetos (que representan tablas en la BD's) y la creación de clases Java para hacer persistentes dichos objetos Java en la base de datos.
__Parte I:__ [Creación de nuevos DAOs y Objetos en AppFuse|CreateDAO] - Esto es un HowTo de cómo crear nuevos Objetos (que representan tablas en la BD's) y la creación de clases Java para hacer persistentes dichos objetos Java en la base de datos.
At line 5 changed 1 line.
Este tutorial nos muestra como crear una nueva tabla en la base de datos, y como crear código Java para acceder a dicha tabla.
Este tutorial nos muestra cómo crear una nueva tabla en la base de datos, y cómo crear código Java para acceder a dicha tabla.
At line 10 changed 1 line.
* Una clase [JUnit|http://www.junit.org] para testear que nuestro DAO funciona :-)
* Una clase [JUnit|http://www.junit.org] para testear que nuestro DAO funciona :-)
At line 12 changed 1 line.
AppFuse utiliza [Hibernate|http://www.hibernate.org] para la capa de persistencia. Hibernate es un Objecto/Relacional (O/R) Framework que nos permite mapear nuestos objetos Java como tablas en la base de datos. Esto nos permite realizar más fácilmente métodos CRUD (Create, Retrieve, Update, Delete) a nuestros objetos (En castellano sería CRAB, Crear-Recibir-Actualizar-Borrar).
AppFuse utiliza [Hibernate|http://www.hibernate.org] para la capa de persistencia. Hibernate es una herramienta Objeto/Relacional (O/R) que nos permite mapear nuestros objetos Java como tablas en la base de datos. Esto nos permite realizar más fácilmente métodos CRUD (Create, Retrieve, Update, Delete) a nuestros objetos (En castellano sería CRAB, Crear-Recibir-Actualizar-Borrar).
At line 14 changed 1 line.
;:''Puedes usar tambi&acutee;n [iBATIS|http://ibatis.com] como capa de persistencia. To install iBATIS in AppFuse, view the README.txt in {{extras/ibatis}}. If you're using iBATIS over Hibernate, I expect you have your reasons and are familiar with the framework. I also expect that you can figure out how to adapt this tutorial to work with iBATIS. ;-)''
;:''Puedes usar también [iBATIS|http://ibatis.com] como capa de persistencia. Para instalar BATIS en AppFuse, refiérase al README.txt que se encuentra en {{extras/ibatis}}. Si prefieres iBATIS sobre Hibernate, espero que tengas tus razones y que estés familiarizado con esa tecnologia. Espero tambien que puedas adaptar este tutorial al usar iBATIS. ;-)''
At line 16 changed 1 line.
;:%%(color: blue)''I will tell you how I do stuff in the __Real World__ in text like this.''%%
;:%%(color: blue)''Te diré como hago las cosas en la práctica en esta guia.''%%
At line 18 changed 1 line.
Let's get started on creating a new Object, DAO and Test in AppFuse's architecture.
Empezaremos creando un nuevo objeto, un DAO y un Test en la arquitectura AppFuse.
At line 20 changed 7 lines.
!Table of Contents
* [1] Create a new Object and add [XDoclet|http://xdoclet.sf.net] tags
* [2] Create a new database table from the object using Ant
* [3] Create a new DaoTest to run JUnit tests on the DAO
* [4] Create a new DAO to perform CRUD on the object
* [5] Configure Spring for the Person object and PersonDao
* [6] Run the DaoTest
!Tabla de contenidos
* [1] Creaci&oacuten de un nuevo Objeto y añadir los tags [XDoclet|http://xdoclet.sf.net]
* [2] Crear una nueva tabla en la base de datos a partir del objeto recién creado usando Ant
* [3] Crear una nueva clase DaoTest que ejecutará los tests JUnit tests en la capa DAO
* [4] Crear una nueva clase DAO que ejecute operaciones Anadir/Lectura/Actualización/Borrado del nuevo objeto Person
* [5] Configurar Spring para el objeto Person y PersonDao
* [6] Ejecutar DaoTest
At line 28 changed 1 line.
!!Create a new Object and add XDoclet tags [#1]
!!Creaci&oacuten de un nuevo Objeto y añadir los tags XDoclet[#1]
At line 30 changed 1 line.
The first thing we need to do is create an object to persist. Let's create a simple "Person" object (in the src/dao/**/model directory) that has an id, a firstName and a lastName (as properties).
Primeramente,necesitamos crear la clase a guardar en la base de datos. Para ello crearemos una clase simple "Person" (en el subdirectorio src/dao/**/model ) que contiene como atributos un id, un firstName y un lastName como atributos.
At line 49 changed 1 line.
;:%%(color: blue)''I usually open an existing object (i.e. User.java or Resume.java) and save it as a new file. Then I delete all the methods and properties. This gives me the basic JavaDoc header. I'm sure I could edit Eclipse templates to do this, but since I develop on 3 different machines, this is just easier.''%%
;:%%(color: blue)''Normalmente edito una clase existente (i.e. User.java o Resume.java) y lo guardo como un nuevo fichero y borro todos los métodos y atributos. Esto me da el encabezamiento básico de JavaDoc. También podria crear templates en Eclipse, pero debido a que programo usando 3 pc distintas, es más fácil hacerlo de la manera anterior.''%%
At line 51 changed 2 lines.
In the code snippet above, we're extending [BaseObject|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/model/BaseObject.java.html] because it has the following useful methods: toString(), equals(), hashCode() - the latter two
are required by Hibernate.
En el código anterior estamos heredando de la clase[BaseObject|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/model/BaseObject.java.html] porque contiene los siguientes métodos : toString(), equals(), hashCode() - los últimos dos son necesarios para el uso de Hibernate.
At line 54 changed 1 line.
Now that we have this POJO created, we need to add XDoclet tags to generate the Hibernate mapping file. This mapping file is used by Hibernate to map objects → tables and properties (variables) → columns.
Ahora que tenemos creado este POJO, necesitamos añadir los tags XDoclet para generar el fichero de mapeo que corresponde a este POJO. Este fichero es usado por Hibrenate para mapear objetos → tablas y atributos (variables) → columnas.
At line 56 changed 1 line.
First of all, we add a [@hibernate.class|http://xdoclet.sourceforge.net/tags/hibernate-tags.html#@hibernate.class%20(0..1)] tag that tells Hibernate what table this object relates to:
Primero, añadiremos un tag [@hibernate.class|http://xdoclet.sourceforge.net/tags/hibernate-tags.html#@hibernate.class%20(0..1)] que indica a Hibernate a que tabla va a estar asociada:
At line 66 changed 1 line.
We also have to add a primary key mapping or XDoclet will puke when generating the mapping file. Note that all @hibernate.* tags should be placed in the __getters'__ Javadocs of your POJOs.
También adicionamos el mapeo para la llave primaria para que XDoclet funcione correctament al general el fichero XML. Note que todos los tags @hibernate deben ponerse en los __getters'__ Javadocs de tus POJOs.
At line 81 changed 1 line.
;:%%(color: blue)''I'm using {{generator-class="increment"}} instead of {{generate-class="native"}} because I [found some issues|AppFuseOnDB2] when using "native" on other databases. If you only plan on using MySQL, I recommend you use the "native" value.''%%
;:%%(color: blue)''Estoy usando {{generator-class="increment"}} en vez de {{generate-class="native"}} porque he [encontrado problemas|AppFuseOnDB2] cuando uso "native" con otras bases de datos. Si solamente planea usar MySQL, le recomiendo que use el valor "native".''%%
At line 83 changed 2 lines.
!!Create a new database table from the object using Ant [#2]
At this point, you can actually create the person table by running "ant setup-db". This task creates the Person.hbm.xml file and creates a database table called "person." From the ant console, you can see the table schema the Hibernate creates for your:
!!Crear una nueva tabla en la base de datos a partir del objeto recién creado usando Ant
[#2]
En este momento podemos crear la tabla Person si ejecutamos "ant setup-db". Esta tarea creará un fichero Person.hbm.xml y una tabla llamada "Person". A partir de la consola de antm puede ver el esquema de la tabla que Hibernate ha creado.
At line 92 changed 1 line.
If you want to look at the Person.hbm.xml file that Hibernate generates for you, look in the build/dao/gen/**/hibernate directory. Here's the contents of Person.hbm.xml (so far):
Si quiere mirar el fichero Person.hbm.xml que generó Hibernate, refiérase al directorio build/dao/gen/**/hibernate. El contenido del fichero Person.hbm.xml es el siguiente (por el momento):
At line 132 changed 1 line.
Now we'll add additional [@hibernate.property|http://xdoclet.sourceforge.net/tags/hibernate-tags.html#@hibernate.property%20(0..1)] tags for our other columns (first_name, last_name):
Ahora adicionaremos otros tags [@hibernate.property|http://xdoclet.sourceforge.net/tags/hibernate-tags.html#@hibernate.property%20(0..1)] para las otras columnas (first_name, last_name):
At line 153 changed 1 line.
In this example, the only reason for adding the ''column'' attribute is because the column name is different from our property name. If they're the same, you don't need to specify the ''column'' attribute. See the [@hibernate.property|http://xdoclet.sourceforge.net/tags/hibernate-tags.html#@hibernate.property%20(0..1)] reference for other attributes you can specify for this tag.
En este ejemplo, la única razón para añadir el atributo ''column'' es porque el nombre de la columna en la tabla es distinto al nombre del atributo. Si son iguales, no hay necesidad de especificar el atributo ''column''. Consulte el manual de referencia [@hibernate.property|http://xdoclet.sourceforge.net/tags/hibernate-tags.html#@hibernate.property%20(0..1)] para otros atributos que se pueden especificar con este tag.
At line 155 changed 1 line.
Run "ant setup-db" again to get the additional columns added to your table.
Ejecute "ant setup-db" para crear las columnas que faltan en la tabla.
At line 164 changed 1 line.
If you want to change the size of your columns, specify a length=''size'' attribute in your @hibernate.property tag. If you want to make it a required field (NOT NULL), add not-null="true".
Si quieres cambiar las dimensiones de las columnas, especifique el atributo length=''size'' en su tag @hibernate.property. Si quieres hacerlo obligatorio(NOT NULL), añada not-null="true".
At line 166 changed 1 line.
!!Create a new DaoTest to run JUnit tests on your DAO [#3]
!!Crear una nueva clase DaoTest que ejecutará los tests JUnit tests en la capa DAO[#3]
At line 168 changed 1 line.
Now we'll create a DaoTest to test our DAO works. "Wait a minute," you say, "we 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.
Ahora crearemos la clase DaoTest y examinaremos como funciona la capa DAO. Me dirás que no hemos creado nuestro DAO, y tienes razón. Sin embargo, he visto que [Test-Driven Development|http://www.artima.com/intv/testdriven.html] contribuye a desarrollar software de mayor calidad. Por años pensé que escribir los tests antes de las clases no tenia sentido, que era estúpido. Pero lo ensayé y vi que funcionaba a las mil maravillas. La unica razón por la que escribo primero los tests es porque acelera el proceso de desarrollo de software.
At line 170 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], 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 automatically 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.
Para empezar, crea una clase PersonDaoTest.java class en el directorio test/dao/**/dao. Esta clase debe extender [BaseDaoTestCase|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/dao/BaseDaoTestCase.java.html], la cual ya existe en este paquete. La clase padre es usada para leer [Spring's|http://www.springframework.org] ApplicationContext (ya que Spring une las distintas capas juntas), para que automáticamente lea un fichero con extension .properties (ResourceBundle) que tenga tenga el mismo nombre que *Test.class.En este ejemplo, si colocas el fichero PersonDaoTest.properties en el mismo directorio que PersonDaoTest.java entonces las propiedades del fichero estarán disponibles via la variable "rb".
At line 172 changed 1 line.
;:%%(color: blue)''I usually copy (open → save as) an existing test (i.e. UserDaoTest.java) and find/replace [[Uu]ser with [[Pp]erson, or whatever the name of my object is.''%%
;:%%(color: blue)''Normalment copio un test existente(open → save as) an existing test (i.e. UserDaoTest.java) y reemplazo [[Uu]ser por [[Pp]erson, o cualquiera que sea el nombre del objeto.''%%
At line 205 changed 1 line.
The code you see above is what we need for a basic JUnit test that initializes and destroys our PersonDao. The "ctx" object is a reference to Spring's ApplicationContext, which is initialized in a static block of the [BaseDaoTestCase's|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/dao/BaseDaoTestCase.java.html] class.
El código anterior es lo que Ud. necesita para realizar una prueba unitaria básica que inicialize y destruya nuestro PersonDao. El objeto "ctx" es una referencia al objeto Application Context de Spring, el cual es inicializado en un bloque estático de la clase [BaseDaoTestCase's|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/dao/BaseDaoTestCase.java.html] .
At line 207 changed 1 line.
Now we need to actually test that the CRUD (create, retrieve, update, delete) methods work in our DAO. To do this we created methods that begin with "test" (all lower case). As long as these methods are public, have a void return type and take no arguments, they will be called by our <junit> task in our Ant build.xml file. Here's some simple tests for testing CRUD. An important thing to remember is that each method (also known as a test), should be autonomous. Add the following methods to your PersonDaoTest.java file:
Ahora necesitamos probar que las operaciones CRUD (create, retrieve, update, delete) methods funcionan en nuestro DAO. Para ello, crearemos metodos que empiecen con el vocablo "test" (en min&uacutesculas). Estos m&eacutet;odos al ser públicos,retornan void y no aceptan par&aacutemetros de entrada, serán ejecutados por la tarea <junit> que se encuentra en el fichero build.xml de Ant .
At line 209 added 2 lines.
Aca le mostramos algunas pruebas sencillas para probar las operaciones CRUD. Lo importante a recordad es que cada m&eacutetodo debe ser aut&oacutenomo. Añada los siguientes métodos a la clase PersonDaoTest.java:
At line 256 changed 1 line.
;:%%(color: blue)''In the testGetPerson method, we're creating a person and then calling a get. I usually enter a record in the database that I can always rely on. Since [DBUnit|http://www.dbunit.org] is used to populate our database with test data before our tests are run, you can simply add the new table/record to the metadata/sql/sample-data.xml file:''%%
;:%%(color: blue)''En el método testGetPerson , estamos creando una persona y luego lo recuperamos de la base de datos. Generalmente adiciono métodos en la base de datos de manera que puedo siempre contar con datos fiables. Debido que [DBUnit|http://www.dbunit.org] es usado para llenar la base de datos con datos para prueba, Ud. puede simplemente añadir una nueva tabla o un record al fichero metadata/sql/sample-data.xml:''%%
At line 273 changed 1 line.
;:%%(color: blue)''This way, you can eliminate the "create new" functionality in the testGetPerson method. If you'd rather add this record directly into the database (via SQL or a GUI), you can rebuild your sample-data.xml file using "ant db-export" and then "cp db-export.xml metadata/sql/sample-data.xml".''%%
;:%%(color: blue)''De esta manera,puedes eliminar la funcionalidad "create new" en el m&eacutetodo testGetPerson. Si prefiere añadir este record directamente a la base de datos , (via SQL o una intefaz GUI), puede reconstruir el fichero sample-data.xml usando "ant db-export" y luego "cp db-export.xml metadata/sql/sample-data.xml".''%%
At line 275 changed 2 lines.
In the above example, you can see that we're calling person.set*(value) to populate our object before saving it. This is easy in this example, but it could get quite cumbersome if we're persisting an object with 10 required fields (not-null="true"). This is why I created the ResourceBundle in the BaseDaoTestCase. Simply create a PersonDaoTest.properties file in the same directory as the PersonDaoTest.java file and define your property values inside it:
;:''I tend to just hard-code test values into Java code - but the .properties file is an option.''
En el ejemplo anterior, Ud. puede que estamos invocando los métodos person.set*(valor) para llenar el objeto antes de guardarlo en la base de datos. Es fácil en este ejemplo , pero puede ser un poco enredoso si queremos persistir un objeto con 10 atributos que sean obligatorios (not-null="true"). Es por esta razon que he creado un ResourceBundle en la clase BaseDaoTestCase. Crea simplemente un fichero PersonDaoTest.properties en el mismo directorio que el fichero PersonDaoTest.java y defina los valores de los atributos:
;:''Normalmente tiendo a definir valores fijos en el código Java - pero el fichero .properties es una opción.''
At line 281 removed 1 line.
Then, rather than calling person.set* to populate your objects, you can use the BaseDaoTestCase.populate(java.lang.Object) method:
At line 284 added 2 lines.
Entonces, en vez de invocar los metodos person.set* para poblar los objetos, puede usar el método BaseDaoTestCase.populate(java.lang.Object) :
At line 289 changed 1 line.
At this point, the PersonDaoTest class won't compile yet because there is no PersonDao.class in our classpath, we need to create it. PersonDAO.java is an interface, and PersonDAOHibernate.java is the Hibernate implementation of that interface. Let's go ahead and create those.
En este momento, la clase PersonDaoTest class no compilará todavia porque no hay ninguna PersonDao.class en el classpath, por lo tanto tenemos que crearlo. PersonDao.java es una interface y la clase PersonDaoHibernate.java es una implementación de esta interface.
At line 291 removed 2 lines.
!!Create a new DAO to perform CRUD on the object [#4]
First off, create a PersonDao.java interface in the src/dao/**/dao directory and specify the basic CRUD methods for any implementation classes. ''I've eliminated the JavaDocs in the class below for display purposes.''
At line 295 added 4 lines.
!!Crear una nueva clase DAO que contenga métodos CRUD [#4]
Primeramente, creemos la interface PersonDao.java en el directorio src/dao/**/dao y especifique los métodos básicos CRUD.
At line 314 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 we need to specify a bean named ''personDAO'' in applicationContext-hibernate.xml. Before we do that, we need to create the PersonDao implementation class.
Note que en la clase anterior no hay ning&uacute;n m&eacute;todo que provoque excepciones.Esto es debido a la manera que funciona [Spring|http://www.springframework.org] ya que considera las Exceptions como RuntimeExceptions. En este momento, Ud. debe ser capaz de compilar todo el c&oacutedigo fuente que se encuentra en src/dao y test/dao usando "ant compile-dao".
Sin embargo, si trata de ejecutar "ant test-dao -Dtestcase=PersonDao", ver&aacute; que hay un error: <span style="color: red">No bean named 'personDao' is defined</span>. Este es un mensaje de error de Spring- indicando que necesitamos especificar un bean llamado ''personDAO'' en el fichero applicationContext-hibernate.xml. Antes de hacer esto, necesitamos crear la clase que implementar&aacute; PersonDao.
At line 316 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.''
;:''La tarea ant para ejecutar pruebas dao tests es llamado "test-dao". Si pasa un par&aacute;metro (usando -Dtestcase=name), Ant buscar&aacute; **/*${testcase}* - permiti&eacute;ndonos pasar Person, PersonDao, o PersonDaoTest - y todas ejecutar&aacute; la clase PersonDaoTest.''
At line 318 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.''
Empecemos la creaci&oacute;n de la clase PeronDAOHibernate que implementa los m&eacute;todos de la clase PersonDao y usa Hibernate para leer/persistir/eliminar la clase Person. Para ello, cree una nueva clase en el directorio src/dao/**/dao/hibernate bajo el nombre PersonDaoHibernate.java. Tambi&eacute;n debe extender [BaseDaoHibernate|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/dao/BaseDAOHibernate.java.html] e implementar la clase PersonDao.
At line 357 changed 1 line.
You'll notice here that we're doing nothing with the ''person'' parameter. This is just a placeholder for now - in the future you may want to filter on it's properties using [Hibernate's Query Language|http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html] (HQL) or using [Criteria Queries|http://www.hibernate.org/hib_docs/reference/en/html/querycriteria.html].
Notar&aacute; que no estamos usando el par&aacute;metro ''person''. En You'll notice here that we're doing nothing with the ''person'' parameter. En este momento sirve s&oacute;lo como variable pero en futuro querr&aacute utilizarla como filtro de sus atributes usando [Hibernate's Query Language|http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html] (HQL) or using [Criteria Queries|http://www.hibernate.org/hib_docs/reference/en/html/querycriteria.html].
At line 359 changed 1 line.
''An example using a Criteria Query:''
''Un ejemplo usando el Criteria Query:''
At line 377 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 we also need to tell it about the Person object.
Ahora, si quiere ejecutar "ant test-dao -Dtestcase=PersonDao", obtendr&aacute; el mismo error. Necesitamos configurar Spring para que sepa que PersonDaoHibernate es una implementaci&oacute;n de PersonDao, y tambi&eacute;n necesitamos indicarle de la existencia de la clase Person.
At line 379 changed 1 line.
!!Configure Spring for the Person object and PersonDao [#5]
!!Configure Spring para la clase Person y PersonDao [#5]
At line 381 changed 1 line.
First, we 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.
Primeramente, necesitamos indicarle a Spring donde se encuentra el fichero de mapeo Hibernate. Para ello, editemos el fichero src/dao/**/dao/hibernate/applicationContext-hibernate.xml y añadimos el fichero {{Person.hbm.xml}} al siguiente bloque.
At line 389 changed 3 lines.
<value>org/appfuse/model/User.hbm.xml</value>
<value>org/appfuse/model/UserCookie.hbm.xml</value>
<value>org/appfuse/model/UserRole.hbm.xml</value>
<value>org/appfuse/model/User.hbm.xml</value>
At line 396 changed 1 line.
Now we 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:
Ahora, necesitamos añadir algo de XML a este fichero para enlazar PersonDaoHibernate a PersonDao. Para ello, añadamos lo siguiente al final del fichero:
At line 406 changed 1 line.
;:''You could also use __autowire="byName"__ to the &lt;bean&gt; and get rid of the "sessionFactory" property. Personally, I like having the dependencies of my objects documented (in XML).''
;:''Podr&iacute; tambi&eacute;n usar __autowire="byName"__ al &lt;bean&gt; y eliminar el atributo "sessionFactory". Personalmente, prefiero documentar las dependencias de los objetos dentro del fichero.''
At line 408 changed 2 lines.
!!Run the DaoTest [#6]
Save all your edited files and try running "ant test-dao -Dtestcase=PersonDao" one more time.
!!Ejecute DaoTest [#6]
Salve los cambios a los ficheros editados y trate de ejecutar "ant test-dao -Dtestcase=PersonDao" .
At line 417 changed 1 line.
''Next Up:'' __Part II:__ [Creating new Managers|CreateManager] - A HowTo for creating [Business Delegates|http://java.sun.com/blueprints/corej2eepatterns/Patterns/BusinessDelegate.html] that talk to the database tier (DAOs) and the web tier (Struts Actions).
''Next Up:'' __Part II:__ [Creando nuevos Managers|CreateManager_es] - A HowTo for creating [Business Delegates|http://java.sun.com/blueprints/corej2eepatterns/Patterns/BusinessDelegate.html] that talk to the database tier (DAOs) and the web tier (Struts Actions).

Back to CreateDAO_es, or to the Page History.