Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

JPA Tools Smoke Test

Revision as of 16:22, 12 November 2007 by Neil.hauge.oracle.com (Talk | contribs)

Project creation

  • Create a J2EE "Utility project" or "New JPA Project" under the "JPA" folder
  • 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

Back to the top