Jump to: navigation, search

Difference between revisions of "JPA Tools Smoke Test"

 
m
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
Project creation
 
Project creation
*Create a J2EE Utility project
+
*Create a "New JPA Project"
 
*Select the "Utility JPA Project with Java 5.0" configuration
 
*Select the "Utility JPA Project with Java 5.0" configuration
*Open the JPA Details and JPA Structure views
+
*Set up a Derby DB and library that contains a JPA implementation
  
 
Java Source test
 
Java Source test
Line 8: Line 8:
 
*Create an attribute and make it the Id for the Entity
 
*Create an attribute and make it the Id for the Entity
 
*Verify that the appropriate annotations have been inserted into the Java source
 
*Verify that the appropriate annotations have been inserted into the Java source
 +
 +
Generate annotated source
 +
*Right-click on the project and select JPA Tools->Generate Entities...
 +
*Examine the generated Entities
 +
*Edit an @Column name to be wrong and ensure that validation picks up the error
  
 
orm.xml test
 
orm.xml test
*
+
*Create a new orm.xml file in the src or meta-inf directory of your Utility project
 +
*Paste in the following content
 +
<pre>
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<entity-mappings version="1.0" xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd">
 +
<!--schema></schema-->
 +
<!--catalog></catalog-->
 +
<access>FIELD</access>
 +
<entity name="EmployeeEntity" class="Employee">
 +
    <table name="Employee"/>
 +
<table-generator name="EMPLOYEE_GENERATOR_TABLE" table="EMP_SEQ" pk-column-name="SEQ_NAME" value-column-name="SEQ_COUNT" pk-column-value="EMP_SEQ"/>
 +
<exclude-default-listeners/>
 +
<exclude-superclass-listeners/>
 +
    <attributes>
 +
<id name="employeeId">
 +
<column name="EMP_ID"/>
 +
<generated-value strategy="TABLE" generator="EMPLOYEE_GENERATOR_TABLE"/>
 +
</id>
 +
<basic name="firstName">
 +
<column name="F_NAME"/>
 +
</basic>
 +
<basic name="lastName">
 +
<column name="L_NAME"/>
 +
</basic>
 +
<one-to-many name="phones" target-entity="Phone" mapped-by="empId">
 +
<cascade>
 +
<cascade-all/>
 +
</cascade>
 +
</one-to-many>
 +
    </attributes>
 +
</entity>
 +
</entity-mappings>
 +
</pre>
 +
*Verify that the JPA structure displays the correct values
 +
*Edit the firstName mapping and confirm that the file and or UI is updated
 +
 
 +
Project Explorer
 +
*Open the Project Explorer view and verify that the content is correct
 +
 
 +
EclipseLink
 +
*Perform all of the above steps to test the EclipseLink extension

Revision as of 11:24, 2 April 2009

Project creation

  • Create a "New JPA Project"
  • Select the "Utility JPA Project with Java 5.0" configuration
  • Set up a Derby DB and library that contains a JPA implementation

Java Source test

  • Create a new Java class in the project and make it an Entity using the JPA Details UI
  • Create an attribute and make it the Id for the Entity
  • Verify that the appropriate annotations have been inserted into the Java source

Generate annotated source

  • Right-click on the project and select JPA Tools->Generate Entities...
  • Examine the generated Entities
  • Edit an @Column name to be wrong and ensure that validation picks up the error

orm.xml test

  • Create a new orm.xml file in the src or meta-inf directory of your Utility project
  • Paste in the following content
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="1.0" xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd">
	<!--schema></schema-->
	<!--catalog></catalog-->
	<access>FIELD</access>
	<entity name="EmployeeEntity" class="Employee">
	    <table name="Employee"/>
		<table-generator name="EMPLOYEE_GENERATOR_TABLE" table="EMP_SEQ" pk-column-name="SEQ_NAME" value-column-name="SEQ_COUNT" pk-column-value="EMP_SEQ"/>
		<exclude-default-listeners/>
		<exclude-superclass-listeners/>
	    <attributes>
			<id name="employeeId">
				<column name="EMP_ID"/>
				<generated-value strategy="TABLE" generator="EMPLOYEE_GENERATOR_TABLE"/>
			</id>
			<basic name="firstName">
				<column name="F_NAME"/>
			</basic>
			<basic name="lastName">
				<column name="L_NAME"/>
			</basic>
			<one-to-many name="phones" target-entity="Phone" mapped-by="empId">
				<cascade>
					<cascade-all/>
				</cascade>
			</one-to-many>
	    </attributes>
	</entity>
</entity-mappings>
  • Verify that the JPA structure displays the correct values
  • Edit the firstName mapping and confirm that the file and or UI is updated

Project Explorer

  • Open the Project Explorer view and verify that the content is correct

EclipseLink

  • Perform all of the above steps to test the EclipseLink extension