Jump to: navigation, search

Difference between revisions of "JPA Tools Smoke Test"

m
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
Project creation
 
Project creation
 
*Create a "New JPA Project"
 
*Create a "New JPA Project"
*Select the "Utility JPA Project with Java 5.0" configuration
+
*Select the "Generic" Platform and "Java 1.7" facet configuration
*Set up a Derby DB and library that contains a JPA implementation
+
*Set up a DB and library that contains a JPA implementation (this can be Oracle, DB2, MySQL, Sybase, etc...)
  
 
Java Source test
 
Java Source test
*Create a new Java class in the project and make it an Entity using the JPA Details UI
+
*Create a JPA Entity in the project and add at least 3 attributes
*Create an attribute and make it the Id for the Entity
+
*Make one of the attributes the Id for the Entity using the JPA Details
 
*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
 
Generate annotated source
*Right-click on the project and select JPA Tools->Generate Entities...
+
*Right-click on the project and select JPA Tools->Generate Entities from Tables...
 
*Examine the generated Entities
 
*Examine the generated Entities
 
*Edit an @Column name to be wrong and ensure that validation picks up the error
 
*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
+
*Create a new orm.xml file in the src or meta-inf directory of your Generic project
 
*Paste in the following content
 
*Paste in the following content
 
<pre>
 
<pre>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?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">
 
<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-->
+
<!--schema></schema-->
 
<!--catalog></catalog-->
 
<!--catalog></catalog-->
 
<access>FIELD</access>
 
<access>FIELD</access>
<entity name="EmployeeEntity" class="Employee">
+
<entity name="model.EmployeeEntity" class="model.Employee">
 
    <table name="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"/>
 
<table-generator name="EMPLOYEE_GENERATOR_TABLE" table="EMP_SEQ" pk-column-name="SEQ_NAME" value-column-name="SEQ_COUNT" pk-column-value="EMP_SEQ"/>
Line 29: Line 29:
 
<exclude-superclass-listeners/>
 
<exclude-superclass-listeners/>
 
    <attributes>
 
    <attributes>
<id name="employeeId">
+
<id name="empId">
 
<column name="EMP_ID"/>
 
<column name="EMP_ID"/>
 
<generated-value strategy="TABLE" generator="EMPLOYEE_GENERATOR_TABLE"/>
 
<generated-value strategy="TABLE" generator="EMPLOYEE_GENERATOR_TABLE"/>
 
</id>
 
</id>
<basic name="firstName">
+
<basic name="fName">
 
<column name="F_NAME"/>
 
<column name="F_NAME"/>
 
</basic>
 
</basic>
<basic name="lastName">
+
<basic name="lName">
 
<column name="L_NAME"/>
 
<column name="L_NAME"/>
 
</basic>
 
</basic>
<one-to-many name="phones" target-entity="Phone" mapped-by="empId">
+
<one-to-many name="phones" target-entity="model.Phone" mapped-by="employee">
 
<cascade>
 
<cascade>
 
<cascade-all/>
 
<cascade-all/>
Line 48: Line 48:
 
</entity-mappings>
 
</entity-mappings>
 
</pre>
 
</pre>
*Verify that the JPA structure displays the correct values
+
*Verify that the JPA structure pane displays the correct values
*Edit the firstName mapping and confirm that the file and or UI is updated
+
*Edit the fName mapping and confirm that the file and or UI is updated
  
 
Project Explorer
 
Project Explorer

Latest revision as of 13:29, 21 August 2013

Project creation

  • Create a "New JPA Project"
  • Select the "Generic" Platform and "Java 1.7" facet configuration
  • Set up a DB and library that contains a JPA implementation (this can be Oracle, DB2, MySQL, Sybase, etc...)

Java Source test

  • Create a JPA Entity in the project and add at least 3 attributes
  • Make one of the attributes the Id for the Entity using the JPA Details
  • 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 from Tables...
  • 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 Generic 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="model.EmployeeEntity" class="model.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="empId">
				<column name="EMP_ID"/>
				<generated-value strategy="TABLE" generator="EMPLOYEE_GENERATOR_TABLE"/>
			</id>
			<basic name="fName">
				<column name="F_NAME"/>
			</basic>
			<basic name="lName">
				<column name="L_NAME"/>
			</basic>
			<one-to-many name="phones" target-entity="model.Phone" mapped-by="employee">
				<cascade>
					<cascade-all/>
				</cascade>
			</one-to-many>
	    </attributes>
	</entity>
</entity-mappings>
  • Verify that the JPA structure pane displays the correct values
  • Edit the fName 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