Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Is there a way to separate notation that define column length?
[Teneo] Is there a way to separate notation that define column length? [message #113014] Fri, 22 February 2008 14:11 Go to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
Hi,

I have a large hibernate.hbm.xml being generated by Teneo from an
standardised XSD. I would like to be able to add the notations for
defining the column lengths (which of course are not specified in the
XSD) but not have them overwritten when I regenerate whenever the
standardized XSD has a new version released. So is it possible to have
these annotations defining the column lengths for the String type
elements and somehow merge them by element name with the generated
hibernate.hbm.xml? Is XSLT my only option?

The other query I had was to do with the generation of a discriminator
column (dtype) by Hibernate. Regardless of which Teneo option
(superclass or joined-subclass) I choose I seems to get this column. The
model I had does not have inheritance for the elements, so I do not need
the discriminator column.

Thx.

David
Re: [Teneo] Is there a way to separate notation that define column length? [message #113027 is a reply to message #113014] Fri, 22 February 2008 14:36 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi David,
You can specify annotations in a separate xml file, see here:
http://www.elver.org/hibernate/ejb3_format.html#xml
Note that you can also specify on edatatype level, so if your string types map to edatatypes in
ecore then you only need to specify the column annotation on the edatatype and it will be re-used in
every location where your string type is used.

When I look at the Teneo testcases I can see that the discriminator is only added in case of
single-table inheritance. Can you check and confirm? If you have a re-producable case then I can
look at it in more detail (just enter a bugzilla in that case).

gr. Martin

david wrote:
> Hi,
>
> I have a large hibernate.hbm.xml being generated by Teneo from an
> standardised XSD. I would like to be able to add the notations for
> defining the column lengths (which of course are not specified in the
> XSD) but not have them overwritten when I regenerate whenever the
> standardized XSD has a new version released. So is it possible to have
> these annotations defining the column lengths for the String type
> elements and somehow merge them by element name with the generated
> hibernate.hbm.xml? Is XSLT my only option?
>
> The other query I had was to do with the generation of a discriminator
> column (dtype) by Hibernate. Regardless of which Teneo option
> (superclass or joined-subclass) I choose I seems to get this column. The
> model I had does not have inheritance for the elements, so I do not need
> the discriminator column.
>
> Thx.
>
> David
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] Is there a way to separate notation that define column length? [message #114667 is a reply to message #113027] Thu, 13 March 2008 18:19 Go to previous messageGo to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
Hi,

Just come back to this. When I select "Generate EMF - Hibernate OR
Mapping (joined-subclass)" I will be generating a hbm fle that supports
a table per subclass and thus have no need for a discriminator column. I
do this and then search the generated hibernate.hbm.xml file for the
keyword discriminator and it does not exist, so far so good. Then I
delete my existing schema and run my HibInit class (based on the
tutorial code) which I assume picks up the hibernate.hbm.xml from the
model directory and uses that to generate the tables.

The trouble is I still get the dtype column in every table. I know I
must be missing something, I searched for a hibernate.hbm.xml that might
be lurking somewhere else but no, it is not.

Here are the porperties again

props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
props.setProperty(Environment.USER, "\gf\");
props.setProperty(Environment.PASS, "\g0rd");
props.setProperty(Environment.URL, "jdbc:mysql://localhost:3306/" +
dbName);
props.setProperty(Environment.DIALECT,
org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
"30");
props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
"false");

props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY, "simple");
props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
"DATE");

props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
"true");
// create the HbDataStore
HbDataStore hbds = HbHelper.INSTANCE.createRegisterDataStore(hbName);

// set the relational database to use and other properties
// to set Teneo specific options call
hbds.setPersistenceProperties(props);
hbds.setHibernateProperties(props);

// sets its epackages stored in this datastore
hbds.setEPackages(new EPackage[]{GensecPackage.eINSTANCE});

Thx.

David

Martin Taal wrote:
> Hi David,
> You can specify annotations in a separate xml file, see here:
> http://www.elver.org/hibernate/ejb3_format.html#xml
> Note that you can also specify on edatatype level, so if your string
> types map to edatatypes in ecore then you only need to specify the
> column annotation on the edatatype and it will be re-used in every
> location where your string type is used.
>
> When I look at the Teneo testcases I can see that the discriminator is
> only added in case of single-table inheritance. Can you check and
> confirm? If you have a re-producable case then I can look at it in more
> detail (just enter a bugzilla in that case).
>
> gr. Martin
>
> david wrote:
>> Hi,
>>
>> I have a large hibernate.hbm.xml being generated by Teneo from an
>> standardised XSD. I would like to be able to add the notations for
>> defining the column lengths (which of course are not specified in the
>> XSD) but not have them overwritten when I regenerate whenever the
>> standardized XSD has a new version released. So is it possible to have
>> these annotations defining the column lengths for the String type
>> elements and somehow merge them by element name with the generated
>> hibernate.hbm.xml? Is XSLT my only option?
>>
>> The other query I had was to do with the generation of a discriminator
>> column (dtype) by Hibernate. Regardless of which Teneo option
>> (superclass or joined-subclass) I choose I seems to get this column.
>> The model I had does not have inheritance for the elements, so I do
>> not need the discriminator column.
>>
>> Thx.
>>
>> David
>>
>>
>
>
Re: [Teneo] Is there a way to separate notation that define column length? [message #114694 is a reply to message #114667] Thu, 13 March 2008 20:26 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi David,
Afaics you did not set the mapping file option for Teneo. Therefore Teneo generates the mapping
in-memory, the default inheritance strategy is single table. So the in-mem mapping will follow that.
There are two ways to solve this:
- if you want to use a statically generated mapping file then set the mapping file option
PersistenceOptions.USE_MAPPING_FILE to true, then Teneo will search in the classpath of the model
package, if your mapping file is located somewhere else then use the MAPPING_FILE_PATH option.
- if you want to use the in-memory mapping logic (which is the same as the menu-driven generation)
then you should pass the INHERITANCE_MAPPING option to the datastore and set it to JOINED

gr. Martin

david wrote:
> Hi,
>
> Just come back to this. When I select "Generate EMF - Hibernate OR
> Mapping (joined-subclass)" I will be generating a hbm fle that supports
> a table per subclass and thus have no need for a discriminator column. I
> do this and then search the generated hibernate.hbm.xml file for the
> keyword discriminator and it does not exist, so far so good. Then I
> delete my existing schema and run my HibInit class (based on the
> tutorial code) which I assume picks up the hibernate.hbm.xml from the
> model directory and uses that to generate the tables.
>
> The trouble is I still get the dtype column in every table. I know I
> must be missing something, I searched for a hibernate.hbm.xml that might
> be lurking somewhere else but no, it is not.
>
> Here are the porperties again
>
> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
> props.setProperty(Environment.USER, "\gf\");
> props.setProperty(Environment.PASS, "\g0rd");
> props.setProperty(Environment.URL,
> "jdbc:mysql://localhost:3306/" + dbName);
> props.setProperty(Environment.DIALECT,
> org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
> "30");
> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
> "false");
>
> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
> "simple");
> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
> "DATE");
>
> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
> "true");
> // create the HbDataStore
> HbDataStore hbds =
> HbHelper.INSTANCE.createRegisterDataStore(hbName);
>
> // set the relational database to use and other properties
> // to set Teneo specific options call
> hbds.setPersistenceProperties(props);
> hbds.setHibernateProperties(props);
>
> // sets its epackages stored in this datastore
> hbds.setEPackages(new EPackage[]{GensecPackage.eINSTANCE});
>
> Thx.
>
> David
>
> Martin Taal wrote:
>> Hi David,
>> You can specify annotations in a separate xml file, see here:
>> http://www.elver.org/hibernate/ejb3_format.html#xml
>> Note that you can also specify on edatatype level, so if your string
>> types map to edatatypes in ecore then you only need to specify the
>> column annotation on the edatatype and it will be re-used in every
>> location where your string type is used.
>>
>> When I look at the Teneo testcases I can see that the discriminator is
>> only added in case of single-table inheritance. Can you check and
>> confirm? If you have a re-producable case then I can look at it in
>> more detail (just enter a bugzilla in that case).
>>
>> gr. Martin
>>
>> david wrote:
>>> Hi,
>>>
>>> I have a large hibernate.hbm.xml being generated by Teneo from an
>>> standardised XSD. I would like to be able to add the notations for
>>> defining the column lengths (which of course are not specified in the
>>> XSD) but not have them overwritten when I regenerate whenever the
>>> standardized XSD has a new version released. So is it possible to
>>> have these annotations defining the column lengths for the String
>>> type elements and somehow merge them by element name with the
>>> generated hibernate.hbm.xml? Is XSLT my only option?
>>>
>>> The other query I had was to do with the generation of a
>>> discriminator column (dtype) by Hibernate. Regardless of which Teneo
>>> option (superclass or joined-subclass) I choose I seems to get this
>>> column. The model I had does not have inheritance for the elements,
>>> so I do not need the discriminator column.
>>>
>>> Thx.
>>>
>>> David
>>>
>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] Is there a way to separate notation that define column length? [message #615545 is a reply to message #113014] Fri, 22 February 2008 14:36 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi David,
You can specify annotations in a separate xml file, see here:
http://www.elver.org/hibernate/ejb3_format.html#xml
Note that you can also specify on edatatype level, so if your string types map to edatatypes in
ecore then you only need to specify the column annotation on the edatatype and it will be re-used in
every location where your string type is used.

When I look at the Teneo testcases I can see that the discriminator is only added in case of
single-table inheritance. Can you check and confirm? If you have a re-producable case then I can
look at it in more detail (just enter a bugzilla in that case).

gr. Martin

david wrote:
> Hi,
>
> I have a large hibernate.hbm.xml being generated by Teneo from an
> standardised XSD. I would like to be able to add the notations for
> defining the column lengths (which of course are not specified in the
> XSD) but not have them overwritten when I regenerate whenever the
> standardized XSD has a new version released. So is it possible to have
> these annotations defining the column lengths for the String type
> elements and somehow merge them by element name with the generated
> hibernate.hbm.xml? Is XSLT my only option?
>
> The other query I had was to do with the generation of a discriminator
> column (dtype) by Hibernate. Regardless of which Teneo option
> (superclass or joined-subclass) I choose I seems to get this column. The
> model I had does not have inheritance for the elements, so I do not need
> the discriminator column.
>
> Thx.
>
> David
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] Is there a way to separate notation that define column length? [message #615868 is a reply to message #113027] Thu, 13 March 2008 18:19 Go to previous message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
Hi,

Just come back to this. When I select "Generate EMF - Hibernate OR
Mapping (joined-subclass)" I will be generating a hbm fle that supports
a table per subclass and thus have no need for a discriminator column. I
do this and then search the generated hibernate.hbm.xml file for the
keyword discriminator and it does not exist, so far so good. Then I
delete my existing schema and run my HibInit class (based on the
tutorial code) which I assume picks up the hibernate.hbm.xml from the
model directory and uses that to generate the tables.

The trouble is I still get the dtype column in every table. I know I
must be missing something, I searched for a hibernate.hbm.xml that might
be lurking somewhere else but no, it is not.

Here are the porperties again

props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
props.setProperty(Environment.USER, "\gf\");
props.setProperty(Environment.PASS, "\g0rd");
props.setProperty(Environment.URL, "jdbc:mysql://localhost:3306/" +
dbName);
props.setProperty(Environment.DIALECT,
org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
"30");
props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
"false");

props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY, "simple");
props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
"DATE");

props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
"true");
// create the HbDataStore
HbDataStore hbds = HbHelper.INSTANCE.createRegisterDataStore(hbName);

// set the relational database to use and other properties
// to set Teneo specific options call
hbds.setPersistenceProperties(props);
hbds.setHibernateProperties(props);

// sets its epackages stored in this datastore
hbds.setEPackages(new EPackage[]{GensecPackage.eINSTANCE});

Thx.

David

Martin Taal wrote:
> Hi David,
> You can specify annotations in a separate xml file, see here:
> http://www.elver.org/hibernate/ejb3_format.html#xml
> Note that you can also specify on edatatype level, so if your string
> types map to edatatypes in ecore then you only need to specify the
> column annotation on the edatatype and it will be re-used in every
> location where your string type is used.
>
> When I look at the Teneo testcases I can see that the discriminator is
> only added in case of single-table inheritance. Can you check and
> confirm? If you have a re-producable case then I can look at it in more
> detail (just enter a bugzilla in that case).
>
> gr. Martin
>
> david wrote:
>> Hi,
>>
>> I have a large hibernate.hbm.xml being generated by Teneo from an
>> standardised XSD. I would like to be able to add the notations for
>> defining the column lengths (which of course are not specified in the
>> XSD) but not have them overwritten when I regenerate whenever the
>> standardized XSD has a new version released. So is it possible to have
>> these annotations defining the column lengths for the String type
>> elements and somehow merge them by element name with the generated
>> hibernate.hbm.xml? Is XSLT my only option?
>>
>> The other query I had was to do with the generation of a discriminator
>> column (dtype) by Hibernate. Regardless of which Teneo option
>> (superclass or joined-subclass) I choose I seems to get this column.
>> The model I had does not have inheritance for the elements, so I do
>> not need the discriminator column.
>>
>> Thx.
>>
>> David
>>
>>
>
>
Re: [Teneo] Is there a way to separate notation that define column length? [message #615871 is a reply to message #114667] Thu, 13 March 2008 20:26 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi David,
Afaics you did not set the mapping file option for Teneo. Therefore Teneo generates the mapping
in-memory, the default inheritance strategy is single table. So the in-mem mapping will follow that.
There are two ways to solve this:
- if you want to use a statically generated mapping file then set the mapping file option
PersistenceOptions.USE_MAPPING_FILE to true, then Teneo will search in the classpath of the model
package, if your mapping file is located somewhere else then use the MAPPING_FILE_PATH option.
- if you want to use the in-memory mapping logic (which is the same as the menu-driven generation)
then you should pass the INHERITANCE_MAPPING option to the datastore and set it to JOINED

gr. Martin

david wrote:
> Hi,
>
> Just come back to this. When I select "Generate EMF - Hibernate OR
> Mapping (joined-subclass)" I will be generating a hbm fle that supports
> a table per subclass and thus have no need for a discriminator column. I
> do this and then search the generated hibernate.hbm.xml file for the
> keyword discriminator and it does not exist, so far so good. Then I
> delete my existing schema and run my HibInit class (based on the
> tutorial code) which I assume picks up the hibernate.hbm.xml from the
> model directory and uses that to generate the tables.
>
> The trouble is I still get the dtype column in every table. I know I
> must be missing something, I searched for a hibernate.hbm.xml that might
> be lurking somewhere else but no, it is not.
>
> Here are the porperties again
>
> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
> props.setProperty(Environment.USER, "\gf\");
> props.setProperty(Environment.PASS, "\g0rd");
> props.setProperty(Environment.URL,
> "jdbc:mysql://localhost:3306/" + dbName);
> props.setProperty(Environment.DIALECT,
> org.hibernate.dialect.MySQLInnoDBDialect.class.getName());
> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
> "30");
> props.setProperty(PersistenceOptions.ID_COLUMN_NAME, "id");
> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
> "false");
>
> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
> "simple");
> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
> "DATE");
>
> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
> "true");
> // create the HbDataStore
> HbDataStore hbds =
> HbHelper.INSTANCE.createRegisterDataStore(hbName);
>
> // set the relational database to use and other properties
> // to set Teneo specific options call
> hbds.setPersistenceProperties(props);
> hbds.setHibernateProperties(props);
>
> // sets its epackages stored in this datastore
> hbds.setEPackages(new EPackage[]{GensecPackage.eINSTANCE});
>
> Thx.
>
> David
>
> Martin Taal wrote:
>> Hi David,
>> You can specify annotations in a separate xml file, see here:
>> http://www.elver.org/hibernate/ejb3_format.html#xml
>> Note that you can also specify on edatatype level, so if your string
>> types map to edatatypes in ecore then you only need to specify the
>> column annotation on the edatatype and it will be re-used in every
>> location where your string type is used.
>>
>> When I look at the Teneo testcases I can see that the discriminator is
>> only added in case of single-table inheritance. Can you check and
>> confirm? If you have a re-producable case then I can look at it in
>> more detail (just enter a bugzilla in that case).
>>
>> gr. Martin
>>
>> david wrote:
>>> Hi,
>>>
>>> I have a large hibernate.hbm.xml being generated by Teneo from an
>>> standardised XSD. I would like to be able to add the notations for
>>> defining the column lengths (which of course are not specified in the
>>> XSD) but not have them overwritten when I regenerate whenever the
>>> standardized XSD has a new version released. So is it possible to
>>> have these annotations defining the column lengths for the String
>>> type elements and somehow merge them by element name with the
>>> generated hibernate.hbm.xml? Is XSLT my only option?
>>>
>>> The other query I had was to do with the generation of a
>>> discriminator column (dtype) by Hibernate. Regardless of which Teneo
>>> option (superclass or joined-subclass) I choose I seems to get this
>>> column. The model I had does not have inheritance for the elements,
>>> so I do not need the discriminator column.
>>>
>>> Thx.
>>>
>>> David
>>>
>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:Teneo: Problem with using QualifyingEntityNameStrategy
Next Topic:teneo:circular loop on DB2 error
Goto Forum:
  


Current Time: Thu Apr 25 16:24:53 GMT 2024

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

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

Back to the top