Hello Jick,
Thank you for taking the time to look at my problem.
I’m afraid I did not make clear that I was using a shortcut notation. When I wrote ~orm I was using the “~” symbol to represent the path to that point, similar to the user’s home directory notation used in Unix/Linux. I am sorry for the misinformation.
In any case, your suggestion was very helpful, it got me onto the right track in resolving my problem.
I am now able to generate working ORM code that requires no modification. I still have a question about some of the generated files, please see that at the end of this post.
For reference, below is a revised list of steps that produces working ORM code.
===============================================
== Third attempt - From ERD - Output dir redefined, Cache disabled, etc.
Notes:
{workspace_dir} is Eclipse workspace, home to all Eclipse projects.
e.g. /Users/glen/Documents/Eclipse/
{project_dir} is the home directory for current project.
e.g. {workspace_dir}/com.arkadias.idemo/
*** indicates changes from First attempt, above.
===============================================
1. Create a new Eclipse project ***
- Create new project in Eclipse: File/New/Project/Java Project
- Project name: com.arkadias.idemo
- Contents: Create new project in workspace
- JRE: use default JRE...
- Project layout: Create separate source and output folders
- {project_dir} is created as: {workspace_dir}/com.arkadias.idemo
2. Install JDBC driver jar ***
- Create {project_dir}/lib
- Copy JDBC driver jar here
- Add JDBC driver jar to Build Path
3. Create Entity Relationship Diagram
- Create new ER diagram in VP-UML
- Assign tables, columns and data types on ERD
4. Create Class diagram from ER diagram
- Create Class diagram from ER diagram
- Tools/Object-Relational Mapping (ORM)/Synchronize to Class Diagram
- Assign <<ORM Persistable>> stereotype as needed
- Assign package to ORM Class Diagram e.g. com.arkadias.idemo.orm
5. Create database and persistable objects (ORM) from ERD
- Create database manually (if needed) e.g. database name idemo
- Generate Code and Database from ERD
- Tools/Object-Relational Mapping (ORM)/Wizards
- Welcome page
- Language: Java
- Wizards: Generate Code and Database from ERD
- Class Details Configuration page
*** - Package: Leave Blank - VP-UML picks up "com.arkadias.idemo.orm" from Class Diagram
- Database Configuration page
*** - Driver file: {project_dir}/com.arkadias.idemo/lib/com.mysql-connector-java-5.0.4-bin.jar
- Provide Connection URL and User data as appropriate
- Confirm Test Connection passes
- Generate Code page
- Error Handling: Throw PesistentException
- Exception Handling: Print to log4j
- Default Lazy Collection Initialization: Lazy for small data set, Extra for large
- Mapping Type: Annotation
*** - Output Path: {project_dir} e.g. /Users/glen/Documents/Eclipse/com.arkadias.idemo/
- Deploy to: (as appropriate for target system) e.g. Standalone Application
- Association Handling: Smart (handles both side of 1 - many updates)
- Persistent API: Factory Class
- Generate Criteria: Check (generates criteria (query) objects)
- Serializable: Check
*** - Cache Options: Disable
- Select Optional Jar: (default)
- Advance Settings: (default)
- Samples: Samples only (generates ORM usage sample code)
- Scripts: None
- Finish to generate Code
- Add {project_dir}/lib/annotations.jar and orm.jar to Build Path
7. Test generated ORM classes
Sample code execution
- CreateIDemoData.java - pass
- DeleteIDemoData.java - pass
- ListIDemoData.java - pass
- RetrieveAndUpdateIDemoData.java - pass
At this point, my Eclipse project looks like this:
http://arkadia-systems.com/images/Eclipse_IDemo_ORM.jpg
My Eclipse/Java project folder looks like this
http://arkadia-systems.com/images/Eclipse_ProjectDir_IDemo.jpg
As noted above, everything works as expected.
There is still a problem with caching, but for clarity, I will open a new thread for that.
I am also wondering if I need to include the ormmapping folder when I package my application for distribution.
Because I chose “Mapping Type: Annotation”, I did not expect this folder to be generated. When I renamed this folder, the sample program files still worked as expected.
Are these files only required for VP-UML to interact with the Java project, or do they serve another purpose?
Your comments on this are much appreciated.
Best regards,
-Glen
