Frequently Asked Questions
UML2 Tools and Profiles
Problems with Magic Draw 14.0+
The export of Magic Draw 14.0+ has a bug. The export as emf/uml2 will do not work correct for the datatypes defined in the Hibernate profile. Workaround: Define the Datatypes inside your model.
Wherefore I need the Persictence Profile?
All needed stereotypes and tagged values are declared inside this profile. Please use the stereotypes inside this profile. For example the Uml Standard Profile also defines a <<entity>>, but this will not work with the hibernate cartridge.
Why are so many different formats (.mdzip, .uml, .uml2) of the profile distributed?
The differned formats are used for different tools. Choose the suitalbe ones for your environment.
How did I configure UML2 modelling tool to work with the Hibernate Cartridge?
Precondition
An UML2 compatible UML Modelling tool. It must be able to save or export the model as .uml2
Tested with:
- Magic Draw 11.6 Community Edition
- Magic Draw 12.0 Community Edition
- Magic Draw 12.5 Community Edition
- Topcased (Eclipse Plugin)
Adding the Persistence Profile
Add the Persistence Profile to your UML project. The profile is part of the release.zip. It is located in the profiles folder. Now you should assign persistence stereotypes to model elements.
Example for Magic Draw 12.0
- Open MagicDraw
- File -> Use Model
- A new Window 'Use Module' appears:
- Browse to the Persistence Profile location, select it and click finish.
- Now the Persistence Profile should appear in the containment view of your project.
I modified the model and saved it, but the generator do not notice the modifications.
The generator reads only the .uml2 file. So, maybe you forgot to export the model again as .uml2 after the change.
Configuration of the Hibernate Cartridge
I want to use another model. Where did I configure the location of my model?
Open the workflow.properties (located in src/main/resources). There you can find the propertie:
#The modelfile
modelfile =src/main/resources/example-model.uml2
Customize it to your needs.
Where did I configure the output location?
oAW defines locations for the generation output. This 'output slots' are called outlets. The Hibernate Cartridge uses three outlets. They are defined in the workflow.properties (located in src/main/resources). Simply customize it to your needs.
#The outlet to use to store code artefacts
outlet.src.dir =${basedir}/src/generated/java
# The outlet to use to store non-code artefacts (configurations, mapping-files and so on)
outlet.res.dir =${basedir}/src/generated/resources
#The outlet to use to store code artefacts. The generator will check
#whether the artifact to generate already exists. If yes the generation of this
#artifact will be skipped.
outlet.src.once.dir = ${basedir}/src/main/java
Modeling
Whats about the Primary key and the <<key>> stereotype?
Every persistent entity saved in a database need a primary key. With the stereotype <<key>> it is possible to define an attribute of an class as a primary key. Note that only one or zero key for every Entity can be modelled. If no primary key is modelled, the Hibernate Cartridge assumes an primary key named id of type long. This relieve you from modeling dozen of keys and helps to holds the model small and simple.
How did I model a new Entity?
Entitys are modeled by a class. At the moment, the stereotype <<Entity>> is assigned to the class, the class is threaten as an Entity.
The following conditions for Entities must be fulfilled:
- The stereotype <<Entity>> must be assigned
- The class must have a name
- The class must assignet to a package
Are Associations between Enities supported?
Sure. Simple draw associations between two Entities. Furthermore the Hibernate Cartridge can differ between different kinds of associations:
'Normal' assosiations
For every assosiation the corresponding properties in the java classes and the hibernate mapping files are generated.
Directed associations
Associations vs. Aggregation & Compositions
The only the hibernate mappings files differs, if you modell aggregations or compositions instead of normal associations. Inside the O/R-mapping files the cascade="" propertie differs.
Multiplicity of associations
The Hibernate Cartridge differ between toMany and toOne associations.
Ordered vs. Unordered associations
The Hibernate Cartridge differs between ordered and unordered associations. If an assosiation is declared as ordered, the propertie in the corresponding Java class is implemented as a list. Also the O/R-mapping is realised as list.
Unlike ordered assosiations, unordered associations are realised as s set (Java class as well as O/R-mapping).
The default setting for associations is unordered.
What about Hibernate supported Types like java.util.Date, java.sql.Time, java.math.BigDecimal ect. ?
To get use of this types, the datatypes have to be created in your modelling tool. Therefore add the datatype to your model. Place it in the right package structure. The datatype should be ready to use.
List of the supported types:
- java.sql.Timestamp
- java.util.Date
- java.sql.Time
- java.math.BigDecimal
- java.math.BigInteger
- java.util.Calendar
- java.util.Locale
- java.util.Currency
- java.util.TimeZone
Note: The mappings for BigDecimal and BigInteger are not working with version 1.2. Version 1.3 provides support for this datatypes.
Example of creating a datatype (java.math.BigDecimal) for MagicDraw:
First of all the package structure have to be generated. So add the packages java and math to your model. Inside the math package choose New Element -> Data Type. Name it BigDecimal.
How to model the Hibernate types text and binary (1.7.0)
- A text is defined as a long String. So you have to model a String with length >= 1000 (The value of the length is not configurable yet).
- A byte-array is mapped to binary. You have to add a uml::PrimitiveType byte[] to your model. Place it directly under your model in the inheritance tree.
How to model primitive boolean?
With Magic Draw 12.5 it is possible to model boolean. But the Fornax Hibernate Cartridge always generate the complex type java.lang.Boolean.
This is an export bug of Magic Draw 12.5. Maybe this bug will be fixed in further versions of Magic Draw. As long as this bug exists, pleas use the following workaround:
Create a PrimitiveType boolean and use it insetad the Magic Draw uml::StandartType::boolean.
Reported Error Messages or further Problems
For any further questions see also the Fornax-Forum
. Many common (Fornax project relevant) problems are discused there. We try to answer as soon as possible. Besides this, we are happy about any fair comment.
errorIfStereotypeMissing ERROR in Version 1.3.0
ERROR - No getter or adder method for property
'errorIfStereotypeMissing in clazz
'org.openarchitectureware.uml2.profile.ProfileMetaModel' found
[errorIfStereotypeMissing=''false'' in
org/fornax/cartridges/uml2/hibernate/hibernate.oaw:51]
ERROR - Workflow interrupted because of configuration errors.
Solution
The version 1.3.0 of the Hibernate Cartridge uses a new version of the oaw-uml-adapter. It can be found in the release inside the lib folder.
Cannot find ./model/reference-model.uml2 (when running with Eclipse)
When running the ant skript, everything works fine. But running the workflow from Eclipse the error:
Cannot find ./model/reference-model.uml2
appears. I configured everything like described in the Tutorial.
Solution
Your workflow.properties are not found and instead of this, the workflow.properties of the reference project of the release is used. But this will not work for you.
It is importand, that the workflow.properties is avaiable in the Eclipse-buildpath (at root, not in subfolders!). Rember: Before you can add an source folder src/main/resources you must remove the source folder src, otherwise Eclipse throws an error message!
Maven error when resolving javax.transaction.jta
When you experience problems with Maven like this:
... Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing:
----------
1) javax.transaction:jta:jar:1.0.1B
Read 1. Installation Guide (CSC), section "Sun Jars".