Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Possible to Override Generation of hibernate.hbm.xml?
[Teneo] Possible to Override Generation of hibernate.hbm.xml? [message #602966] Tue, 27 February 2007 16:15
Eclipse UserFriend
Originally posted by: bsu.bergauer.ch

Hi,

I have some problems getting in control of the id and version columns in my
project. I need to have those attributes both in the ecore and in my model
interface (non synthetic), in the EMF-Editor, however, they are not visible.

I tried to set persistency annotations in the model interfaces with little
success:

FOR THE ID COLUMN:
/**
* @model id="true" required="true"
* @generated
*/
@Id @GeneratedValue(strategy=GenerationType.AUTO)
int getId();

/**
* @generated
*/
void setId(int value);

RESULT: org.hibernate.id.IdentifierGenerationException: ids for this class
must be manually assigned before calling save()
(I notice that the generated PK `id` is auto_increment in
MySql)

FOR THE VERSION COLUMN:
/**
* @model required="true"
* @generated
*/
@Version
int getVersion();

/**
* @generated
*/
void setVersion(int value);

RESULT: org.hibernate.MappingException: Duplicate property mapping of
version found

As I will have quite some tables in my model I'm not so keen in modifying
all generated model interfaces in order to add any annotations. What I
rather would like is to utilize the Teneo utility and so generate EMF -
Hibernate OR mapping direct from the ecore file. In order to do that I have
added persistenceProperties.setProperty(PersistenceOptions.USE_MAP PING_FILE,
"true"); to the persistency property in the EditorPlugin. The generated
hibernate.hbm.xml has anyway to be modified in the following way:

GENERATED:
<id name="id" type="int">
<column not-null="true" unique="false" name="`id`"/>
</id>

MODIFIED:
<id name="id" type="int" column="id" unsaved-value="0">
<generator class="identity"/>
</id>

GENERATED:
<version name="version" column="version"
access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHand
ler">
<meta attribute="syntheticVersion">true</meta>
</version>

MODIFIED:
<version name="version" column="version"
access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHand
ler"/>

With the above modifications my EMF-Editor is working and I have no problems
persisting the model objects to the database. Ids are generated and version
is incremented.

My question is if one somehow can override the mappings being generated in
order to achieve above modified id- and version-elements?

Thanks,
Bj
Previous Topic:[Teneo] Embeddable annotation?
Next Topic:[Teneo] Can't seem to access objects in store
Goto Forum:
  


Current Time: Thu Apr 25 20:13:42 GMT 2024

Powered by FUDForum. Page generated in 0.02904 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top