TS 65 HibernateSupport
Hibernate Support Test Specification for NetBeans 6.7
Version: 1.0
Estimated time: 2 hours
Last update: 2008/01/30
Introduction: This document contains procedures for testing Hibernate Support.
Requirements: Mysql sakila db sample connected in the IDE.
Comments:
Contents |
Test suite: Project support (Java Web project)
- Create new project w/ Hibernate Framework.
- Start new project wizard.
- Add Hibernate Framework on Frameworks page of the wizard.
- Select sakila db ()
- Finish the wizard
- EXPECTED RESULT: hibernate.cfg.xml file should be created in Source Packages/<default package>, file content should look like this:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/sakila</property> <property name="hibernate.connection.username">username</property> <property name="hibernate.connection.password">password</property> </session-factory> </hibernate-configuration>
- Create new Project w/o Hibenrate and add it using the Customizer.
- Create a new Web Project:
- Open project Properties
- Add the Hibernate Framework with sakila db connection
- EXPECTED RESULT: hibernate.cfg.xml file should be created in Source Packages/<default package> content should look like the example above.
Test suite: hibernate.cfg.xml multiview editor
- Check multiview editor
- Open the hibernate.cfg.xml file
- Select the Design view
- Make some change in the JDBC part: chage username, password
- EXPECTED RESULT: select the XML view and check weeather the changes
- Repeat this steps for next parts of the Design view
Test suite: Hibernate Reverse Engineering
- Create new web project with the Spring Web MVC framework
- Start New Mapping Files and POJOs from Database wizard (bug 198524)
- on the second page of the wizard select all available tables
- on the third page type arbitrary package name (repeat the wizard with checked/unchecked JDK5 features and for EJB3 annotations)
- finish the wizard
- EXPECTED RESULT: HBM files should be generated for every table. Those files should contain property mapping as well as relationship mappings. See the following example:
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Generated Jan 20, 2009 4:04:26 PM by Hibernate Tools 3.2.1.GA --> <hibernate-mapping> <class name="test.Actor" table="actor" catalog="sakila"> <id name="actorId" type="java.lang.Short"> <column name="actor_id" /> <generator class="identity" /> </id> <property name="firstName" type="string"> <column name="first_name" length="45" not-null="true" /> </property> <property name="lastName" type="string"> <column name="last_name" length="45" not-null="true" /> </property> <property name="lastUpdate" type="timestamp"> <column name="last_update" length="0" not-null="true" /> </property> <set name="filmActors" inverse="true"> <key> <column name="actor_id" not-null="true" /> </key> <one-to-many class="test.FilmActor" /> </set> </class> </hibernate-mapping>
POJOs should be generated for every table. This should be plain java class containing fields for every column.
The hiebrnate.cfg.xml file should contain links to the HBMs:
... <mapping resource="test/Address.hbm.xml"/> <mapping resource="test/Inventory.hbm.xml"/> <mapping resource="test/Actor.hbm.xml"/> ...
Test suite: HQL Editor
- Create new project w/ Hibernate Framework.
- Invoke Run HQL action from cntx. menu on hibernate.cfg.xml
- Run a query
select a from Actor a
- EXPECTED RESULT: result should be consistent with equivalent SQL query:
select * from actor