Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY
[Teneo] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #90001] Tue, 17 July 2007 11:19 Go to next message
Roman Bliznets is currently offline Roman BliznetsFriend
Messages: 75
Registered: July 2009
Member
Hello, I'm updated teneo version to 0.8.0.v200707121518,
I want to use new version in order to correct
https://bugs.eclipse.org/bugs/show_bug.cgi?id=185717 bug.

Casused exception:
org.hibernate.MappingException: Foreign key
(FKF8C83C375882C2E:dtsadd_paymentdescription [dtsadditionalpaymentst_id]))
must have same number of columns as the referenced primary key
(dtsadditionalpaymentstype
[dtsadditionalpaymentst_id,dtsadditionalpayments_idx])
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.jav a:90)
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.jav a:73)
....

Should I use some persistence options?

I tried to use PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY with "unique"
options, but it was useless.

code:
....
final Properties persisence=new Properties();
persisence.put(PersistenceOptions.JOIN_TABLE_NAMING_STRATEGY , "ejb3");
persisence.put(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH, "25");
persisence.put(PersistenceOptions.INHERITANCE_MAPPING, "JOINED");
// persisence.put(PersistenceOptions.PERSISTENCE_XML , "persistence.xml");
// used earlier
persisence.put(PersistenceOptions.JOIN_COLUMN_NAMING_STRATEG Y, "unique");
hbds.setPersistenceProperties(persisence);

I used to use persistence mapping file, but now it doesn't help.What wrong?
Re: [Teneo] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #90017 is a reply to message #90001] Tue, 17 July 2007 11:45 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Can you post the part of the generated hbm which covers this assocation?

gr. Martin

wolf_roma wrote:
> Hello, I'm updated teneo version to 0.8.0.v200707121518,
> I want to use new version in order to correct
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=185717 bug.
>
> Casused exception:
> org.hibernate.MappingException: Foreign key
> (FKF8C83C375882C2E:dtsadd_paymentdescription [dtsadditionalpaymentst_id]))
> must have same number of columns as the referenced primary key
> (dtsadditionalpaymentstype
> [dtsadditionalpaymentst_id,dtsadditionalpayments_idx])
> at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.jav a:90)
> at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.jav a:73)
> ....
>
> Should I use some persistence options?
>
> I tried to use PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY with "unique"
> options, but it was useless.
>
> code:
> ....
> final Properties persisence=new Properties();
> persisence.put(PersistenceOptions.JOIN_TABLE_NAMING_STRATEGY , "ejb3");
> persisence.put(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH, "25");
> persisence.put(PersistenceOptions.INHERITANCE_MAPPING, "JOINED");
> // persisence.put(PersistenceOptions.PERSISTENCE_XML , "persistence.xml");
> // used earlier
> persisence.put(PersistenceOptions.JOIN_COLUMN_NAMING_STRATEG Y, "unique");
> hbds.setPersistenceProperties(persisence);
>
> I used to use persistence mapping file, but now it doesn't help.What wrong?
>
>


--

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] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #90032 is a reply to message #90017] Tue, 17 July 2007 12:13 Go to previous messageGo to next message
Roman Bliznets is currently offline Roman BliznetsFriend
Messages: 75
Registered: July 2009
Member
I cann't, because exception caused in hbds.initialize() method and hbm
mapping isn't generated yet.
I can post ecore model or old hbm mapping:
old hbm.xml:
--------------------------------------------
......
<class
name=" customs.ru.esaddts.common.aggregate.types._3._0._1.impl.DTSA dditionalPaymentsTypeImpl "
entity-name="DTSAdditionalPaymentsType" abstract="false" lazy="false"
table="`dtsadditionalpaymentstype`">
<meta attribute="eclassName">DTSAdditionalPaymentsType</meta>
<meta
attribute="epackage">urn:customs.ru:ESADDTSCommonAggregateTypes:3.0.1 </meta>
<id type="long" name="e_id" column="e_id"
access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
<meta attribute="syntheticId">true</meta>
<generator class="native"/>
</id>
<version name="e_version" column="e_version"
access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
<meta attribute="syntheticVersion">true</meta>
</version>
<property name="column9A" lazy="false" insert="true" update="true"
not-null="true" unique="false" type="java.lang.String">
<column not-null="false" unique="false" name="`column9a`" length="1"/>
</property>
<property name="column9B" lazy="false" insert="true" update="true"
not-null="true" unique="false" type="java.lang.String">
<column not-null="false" unique="false" name="`column9b`" length="1"/>
</property>
<list name="paymentDescription" lazy="true" cascade="all,delete-orphan">
<key update="true">
<column name="`dtsadditionalpaymentst_id`" not-null="true"
unique="false"/>
</key>
<list-index column="`dtsadditionalpayments_idx`"/>
<element type="java.lang.String"/>
</list>
<list name="paymentConditionDescription" lazy="true"
cascade="all,delete-orphan">
<key update="true">
<column name="`dtsadditionalpaymentst_id`" not-null="true"
unique="false"/>
</key>
<list-index column="`dtsadditionalpayments_idx`"/>
<element type="java.lang.String"/>
</list>
</class>
......
<joined-subclass
name=" customs.ru.information.customs.documents.dt.sout._3._0._1.im pl.DTSoutTypeImpl "
entity-name="DTSoutType" abstract="false" lazy="false" extends="BaseDocType"
table="`dtsouttype`">
<meta attribute="eclassName">DTSoutType</meta>
<meta
attribute="epackage">urn:customs.ru:Information:CustomsDocuments:DTSout:3.0.1 </meta>
<many-to-one name="dTSAdditionalPayments"
entity-name="DTSAdditionalPaymentsType" cascade="all" lazy="false"
insert="true" update="true" not-null="false">
<column not-null="false" unique="false"
name="`dtsadditionalpaymentst_id`"/>
</many-to-one>
....
</joined-subclass>
....






  • Attachment: model.rar
    (Size: 57.62KB, Downloaded 138 times)
Re: [Teneo] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #90047 is a reply to message #90032] Tue, 17 July 2007 12:14 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
It should be possible to call getMappingXML() after the exception and still get the mapping out of
de datastore. It really helps if I can the difference between the old and the new hbm.

gr. Martin

wolf_roma wrote:
> I cann't, because exception caused in hbds.initialize() method and hbm
> mapping isn't generated yet.
> I can post ecore model or old hbm mapping:
> old hbm.xml:
> --------------------------------------------
> ......
> <class
> name=" customs.ru.esaddts.common.aggregate.types._3._0._1.impl.DTSA dditionalPaymentsTypeImpl "
> entity-name="DTSAdditionalPaymentsType" abstract="false" lazy="false"
> table="`dtsadditionalpaymentstype`">
> <meta attribute="eclassName">DTSAdditionalPaymentsType</meta>
> <meta
> attribute="epackage">urn:customs.ru:ESADDTSCommonAggregateTypes:3.0.1 </meta>
> <id type="long" name="e_id" column="e_id"
> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
> <meta attribute="syntheticId">true</meta>
> <generator class="native"/>
> </id>
> <version name="e_version" column="e_version"
> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
> <meta attribute="syntheticVersion">true</meta>
> </version>
> <property name="column9A" lazy="false" insert="true" update="true"
> not-null="true" unique="false" type="java.lang.String">
> <column not-null="false" unique="false" name="`column9a`" length="1"/>
> </property>
> <property name="column9B" lazy="false" insert="true" update="true"
> not-null="true" unique="false" type="java.lang.String">
> <column not-null="false" unique="false" name="`column9b`" length="1"/>
> </property>
> <list name="paymentDescription" lazy="true" cascade="all,delete-orphan">
> <key update="true">
> <column name="`dtsadditionalpaymentst_id`" not-null="true"
> unique="false"/>
> </key>
> <list-index column="`dtsadditionalpayments_idx`"/>
> <element type="java.lang.String"/>
> </list>
> <list name="paymentConditionDescription" lazy="true"
> cascade="all,delete-orphan">
> <key update="true">
> <column name="`dtsadditionalpaymentst_id`" not-null="true"
> unique="false"/>
> </key>
> <list-index column="`dtsadditionalpayments_idx`"/>
> <element type="java.lang.String"/>
> </list>
> </class>
> ......
> <joined-subclass
> name=" customs.ru.information.customs.documents.dt.sout._3._0._1.im pl.DTSoutTypeImpl "
> entity-name="DTSoutType" abstract="false" lazy="false" extends="BaseDocType"
> table="`dtsouttype`">
> <meta attribute="eclassName">DTSoutType</meta>
> <meta
> attribute="epackage">urn:customs.ru:Information:CustomsDocuments:DTSout:3.0.1 </meta>
> <many-to-one name="dTSAdditionalPayments"
> entity-name="DTSAdditionalPaymentsType" cascade="all" lazy="false"
> insert="true" update="true" not-null="false">
> <column not-null="false" unique="false"
> name="`dtsadditionalpaymentst_id`"/>
> </many-to-one>
> ....
> </joined-subclass>
> ....
>
>
>
>
>
>


--

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] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #90063 is a reply to message #90047] Tue, 17 July 2007 12:43 Go to previous messageGo to next message
Roman Bliznets is currently offline Roman BliznetsFriend
Messages: 75
Registered: July 2009
Member
Ok, I'm attachnew hbm, old hbm and old persistence...
:)


Re: [Teneo] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #90077 is a reply to message #90063] Tue, 17 July 2007 12:47 Go to previous messageGo to next message
Roman Bliznets is currently offline Roman BliznetsFriend
Messages: 75
Registered: July 2009
Member
entirely foghot, archive description:
persistence.xml - old persistence
hbm.xml - it old hbm
hbm1.xml - it new hbm
Re: [Teneo] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #90137 is a reply to message #90077] Tue, 17 July 2007 14:51 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Thanks, I noticed the following differences:
- the persistence.xml did not seem to be picked up (at least not for the join tables)
- Teneo now adds a column tag to a key (this is probably were your exception comes from, although my
testcases don't get this exception)
- Teneo does not recognize your date fields as such (they are mapped as strings)
- Teneo adds a scale="0" to numeric columns

Can you send me the ecore file or if that is easier the model project? I can analyze why the
differences occur and repair this (if relevant).

Which options do you use to generate the hbm's?

gr. Martin

wolf_roma wrote:
> entirely foghot, archive description:
> persistence.xml - old persistence
> hbm.xml - it old hbm
> hbm1.xml - it new hbm
>
>


--

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] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #90288 is a reply to message #90137] Wed, 18 July 2007 07:42 Go to previous messageGo to next message
Roman Bliznets is currently offline Roman BliznetsFriend
Messages: 75
Registered: July 2009
Member
Hello.
1. Scale=0 - I a bit changed code for generation numeric filed: if exist
precision attribute always adding scale attribute (doesn't matter scale
contain default value or not). It fix same bug but I don't know whose its
bug (hibernate or teneo or mine or etc :))))) )
--- Most likely, it's hibernate bug and I don't post its in this
forum(news).
2. Ecore files: I attached their previous in 3th post (model.rar)
3. I used persistence.xml before, with this bug it useless
Re: [Teneo] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #90301 is a reply to message #90288] Wed, 18 July 2007 07:46 Go to previous messageGo to next message
Roman Bliznets is currently offline Roman BliznetsFriend
Messages: 75
Registered: July 2009
Member
Create datastore...

public SessionFactory getSessionFactory() {
if(sessionFactory==null){
PropertyConfigurator.configure("log4j.properties");
// create the HbDataStore
hbds = (HbDataStore)HbHelper.INSTANCE.createRegisterDataStore("mySF ");

final Properties props = new Properties();
props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
props.setProperty(Environment.USER, "root");
props.setProperty(Environment.URL, "jdbc:mysql://localhost/test");
props.setProperty(Environment.PASS, "rootpassword");
props.setProperty(Environment.DIALECT,
org.hibernate.dialect.MySQLDialect.class.getName());
props.setProperty(Environment.SHOW_SQL, "true");
// props.setProperty(Environment.HBM2DDL_AUTO, "update");
hbds.setHibernateProperties(props);

final Properties persisence=new Properties();
persisence.put(PersistenceOptions.JOIN_TABLE_NAMING_STRATEGY , "ejb3");
// persisence.put(PersistenceOptions.UPDATE_SCHEMA, "true");
persisence.put(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH, "25");
persisence.put(PersistenceOptions.INHERITANCE_MAPPING, "JOINED");
persisence.put(PersistenceOptions.PERSISTENCE_XML , "persistence.xml");
// persisence.put(PersistenceOptions.JOIN_COLUMN_NAMING_STRATEG Y,
"unique");
hbds.setPersistenceProperties(persisence);

// sets its epackages stored in this datastore
EPackage[] packages = new EPackage[]{_1Package.eINSTANCE,
_0Package.eINSTANCE,
customs.ru.common.aggregate.types._3._0._1._1Package.eINSTAN CE,
customs.ru.common.leaf.types._3._0._1._1Package.eINSTANCE,
customs.ru.esad.common.aggregate.types._3._0._1._1Package.eI NSTANCE,
customs.ru.esad.common.leaf.types._3._0._1._1Package.eINSTAN CE,
customs.ru.information.customs.documents.dt.sout._3._0._1._1 Package.eINSTANCE,
customs.ru.esaddts.common.aggregate.types._3._0._1._1Package .eINSTANCE,
customs.ru.ekts.common.aggregate.types._3._0._1._1Package.eI NSTANCE,
customs.ru.information.customs.documents.kt.sout._3._0._1._1 Package.eINSTANCE};
hbds.setEPackages(packages);

// initialize, also creates the database tables
hbds.initialize();
//take xml mapping into file (for debug)
writeMappingXML();


sessionFactory = hbds.getSessionFactory();
}
return sessionFactory;
}
Re: [Teneo] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #90331 is a reply to message #90301] Wed, 18 July 2007 09:45 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Thanks, yes I found the ecores.

>> Scale
The scale is read from the annotation meta data (fractionDigits), this should be okay.

>> Different Date mapping
It was the other way around the latest Teneo release now correctly identifies the date types,
therefore it does not use typedef's in the top of the hbm anymore. This also means however that the
mapping to the database has changed (it uses a date column instead of a string column).

>> The Exception
I tested this and the exception was caused by the following bug (or feature):
The latest release of Teneo now also computes the table name for list of primitive types. This table
name computation also does truncation if the name is too long (according to the options).
The problem with truncation logic is that it can result in non-unique naming (as the unique part is
truncated away).
This resulted in a eclass and a list of primitive string to be placed in the same table. You can
search the new hbm for the text table="`dtsadditionalpaymentstype`" and then you will see it appear
twice.
The primitive list causes this table to have two columns in the pk (the id and the idx).

I solved this by changing the truncation logic (there was a bug in it actually which caused it to
truncate away the wrong part). This will be in the next build.

Note that the new join table naming logic for primitive lists means that the generated hbm is not
backward compatible with the old db schema (only if the names are too long). So you need to use
jointable annotations to force Teneo to use the old tablenames (or transfer to a new db-schema).

Btw, the latest Teneo release offers an easier method to extend or override the sql naming strategy
(see extensions on the elver.org website).

gr. Martin


wolf_roma wrote:
> Create datastore...
>
> public SessionFactory getSessionFactory() {
> if(sessionFactory==null){
> PropertyConfigurator.configure("log4j.properties");
> // create the HbDataStore
> hbds = (HbDataStore)HbHelper.INSTANCE.createRegisterDataStore("mySF ");
>
> final Properties props = new Properties();
> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
> props.setProperty(Environment.USER, "root");
> props.setProperty(Environment.URL, "jdbc:mysql://localhost/test");
> props.setProperty(Environment.PASS, "rootpassword");
> props.setProperty(Environment.DIALECT,
> org.hibernate.dialect.MySQLDialect.class.getName());
> props.setProperty(Environment.SHOW_SQL, "true");
> // props.setProperty(Environment.HBM2DDL_AUTO, "update");
> hbds.setHibernateProperties(props);
>
> final Properties persisence=new Properties();
> persisence.put(PersistenceOptions.JOIN_TABLE_NAMING_STRATEGY , "ejb3");
> // persisence.put(PersistenceOptions.UPDATE_SCHEMA, "true");
> persisence.put(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH, "25");
> persisence.put(PersistenceOptions.INHERITANCE_MAPPING, "JOINED");
> persisence.put(PersistenceOptions.PERSISTENCE_XML , "persistence.xml");
> // persisence.put(PersistenceOptions.JOIN_COLUMN_NAMING_STRATEG Y,
> "unique");
> hbds.setPersistenceProperties(persisence);
>
> // sets its epackages stored in this datastore
> EPackage[] packages = new EPackage[]{_1Package.eINSTANCE,
> _0Package.eINSTANCE,
> customs.ru.common.aggregate.types._3._0._1._1Package.eINSTAN CE,
> customs.ru.common.leaf.types._3._0._1._1Package.eINSTANCE,
> customs.ru.esad.common.aggregate.types._3._0._1._1Package.eI NSTANCE,
> customs.ru.esad.common.leaf.types._3._0._1._1Package.eINSTAN CE,
> customs.ru.information.customs.documents.dt.sout._3._0._1._1 Package.eINSTANCE,
> customs.ru.esaddts.common.aggregate.types._3._0._1._1Package .eINSTANCE,
> customs.ru.ekts.common.aggregate.types._3._0._1._1Package.eI NSTANCE,
> customs.ru.information.customs.documents.kt.sout._3._0._1._1 Package.eINSTANCE};
> hbds.setEPackages(packages);
>
> // initialize, also creates the database tables
> hbds.initialize();
> //take xml mapping into file (for debug)
> writeMappingXML();
>
>
> sessionFactory = hbds.getSessionFactory();
> }
> return sessionFactory;
> }
>
>


--

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] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #90362 is a reply to message #90331] Wed, 18 July 2007 10:26 Go to previous messageGo to next message
Roman Bliznets is currently offline Roman BliznetsFriend
Messages: 75
Registered: July 2009
Member
Thanks.
Where bug fix in next release or next build?
When will the new build be?
Re: [Teneo] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #90425 is a reply to message #90362] Wed, 18 July 2007 11:27 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Build and release is the same for Teneo, I hope to do a new build today, otherwise it will be tomorrow.

gr. Martin

wolf_roma wrote:
> Thanks.
> Where bug fix in next release or next build?
> When will the new build be?
>
>
>
>


--

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] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #608762 is a reply to message #90001] Tue, 17 July 2007 11:45 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Can you post the part of the generated hbm which covers this assocation?

gr. Martin

wolf_roma wrote:
> Hello, I'm updated teneo version to 0.8.0.v200707121518,
> I want to use new version in order to correct
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=185717 bug.
>
> Casused exception:
> org.hibernate.MappingException: Foreign key
> (FKF8C83C375882C2E:dtsadd_paymentdescription [dtsadditionalpaymentst_id]))
> must have same number of columns as the referenced primary key
> (dtsadditionalpaymentstype
> [dtsadditionalpaymentst_id,dtsadditionalpayments_idx])
> at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.jav a:90)
> at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.jav a:73)
> ....
>
> Should I use some persistence options?
>
> I tried to use PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY with "unique"
> options, but it was useless.
>
> code:
> ....
> final Properties persisence=new Properties();
> persisence.put(PersistenceOptions.JOIN_TABLE_NAMING_STRATEGY , "ejb3");
> persisence.put(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH, "25");
> persisence.put(PersistenceOptions.INHERITANCE_MAPPING, "JOINED");
> // persisence.put(PersistenceOptions.PERSISTENCE_XML , "persistence.xml");
> // used earlier
> persisence.put(PersistenceOptions.JOIN_COLUMN_NAMING_STRATEG Y, "unique");
> hbds.setPersistenceProperties(persisence);
>
> I used to use persistence mapping file, but now it doesn't help.What wrong?
>
>


--

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] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #608763 is a reply to message #90017] Tue, 17 July 2007 12:13 Go to previous message
Roman Bliznets is currently offline Roman BliznetsFriend
Messages: 75
Registered: July 2009
Member
I cann't, because exception caused in hbds.initialize() method and hbm
mapping isn't generated yet.
I can post ecore model or old hbm mapping:
old hbm.xml:
--------------------------------------------
......
<class
name=" customs.ru.esaddts.common.aggregate.types._3._0._1.impl.DTSA dditionalPaymentsTypeImpl "
entity-name="DTSAdditionalPaymentsType" abstract="false" lazy="false"
table="`dtsadditionalpaymentstype`">
<meta attribute="eclassName">DTSAdditionalPaymentsType</meta>
<meta
attribute="epackage">urn:customs.ru:ESADDTSCommonAggregateTypes:3.0.1 </meta>
<id type="long" name="e_id" column="e_id"
access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
<meta attribute="syntheticId">true</meta>
<generator class="native"/>
</id>
<version name="e_version" column="e_version"
access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
<meta attribute="syntheticVersion">true</meta>
</version>
<property name="column9A" lazy="false" insert="true" update="true"
not-null="true" unique="false" type="java.lang.String">
<column not-null="false" unique="false" name="`column9a`" length="1"/>
</property>
<property name="column9B" lazy="false" insert="true" update="true"
not-null="true" unique="false" type="java.lang.String">
<column not-null="false" unique="false" name="`column9b`" length="1"/>
</property>
<list name="paymentDescription" lazy="true" cascade="all,delete-orphan">
<key update="true">
<column name="`dtsadditionalpaymentst_id`" not-null="true"
unique="false"/>
</key>
<list-index column="`dtsadditionalpayments_idx`"/>
<element type="java.lang.String"/>
</list>
<list name="paymentConditionDescription" lazy="true"
cascade="all,delete-orphan">
<key update="true">
<column name="`dtsadditionalpaymentst_id`" not-null="true"
unique="false"/>
</key>
<list-index column="`dtsadditionalpayments_idx`"/>
<element type="java.lang.String"/>
</list>
</class>
......
<joined-subclass
name=" customs.ru.information.customs.documents.dt.sout._3._0._1.im pl.DTSoutTypeImpl "
entity-name="DTSoutType" abstract="false" lazy="false" extends="BaseDocType"
table="`dtsouttype`">
<meta attribute="eclassName">DTSoutType</meta>
<meta
attribute="epackage">urn:customs.ru:Information:CustomsDocuments:DTSout:3.0.1 </meta>
<many-to-one name="dTSAdditionalPayments"
entity-name="DTSAdditionalPaymentsType" cascade="all" lazy="false"
insert="true" update="true" not-null="false">
<column not-null="false" unique="false"
name="`dtsadditionalpaymentst_id`"/>
</many-to-one>
....
</joined-subclass>
....






  • Attachment: model.rar
    (Size: 57.62KB, Downloaded 96 times)
Re: [Teneo] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #608764 is a reply to message #90032] Tue, 17 July 2007 12:14 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
It should be possible to call getMappingXML() after the exception and still get the mapping out of
de datastore. It really helps if I can the difference between the old and the new hbm.

gr. Martin

wolf_roma wrote:
> I cann't, because exception caused in hbds.initialize() method and hbm
> mapping isn't generated yet.
> I can post ecore model or old hbm mapping:
> old hbm.xml:
> --------------------------------------------
> ......
> <class
> name=" customs.ru.esaddts.common.aggregate.types._3._0._1.impl.DTSA dditionalPaymentsTypeImpl "
> entity-name="DTSAdditionalPaymentsType" abstract="false" lazy="false"
> table="`dtsadditionalpaymentstype`">
> <meta attribute="eclassName">DTSAdditionalPaymentsType</meta>
> <meta
> attribute="epackage">urn:customs.ru:ESADDTSCommonAggregateTypes:3.0.1 </meta>
> <id type="long" name="e_id" column="e_id"
> access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
> <meta attribute="syntheticId">true</meta>
> <generator class="native"/>
> </id>
> <version name="e_version" column="e_version"
> access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
> <meta attribute="syntheticVersion">true</meta>
> </version>
> <property name="column9A" lazy="false" insert="true" update="true"
> not-null="true" unique="false" type="java.lang.String">
> <column not-null="false" unique="false" name="`column9a`" length="1"/>
> </property>
> <property name="column9B" lazy="false" insert="true" update="true"
> not-null="true" unique="false" type="java.lang.String">
> <column not-null="false" unique="false" name="`column9b`" length="1"/>
> </property>
> <list name="paymentDescription" lazy="true" cascade="all,delete-orphan">
> <key update="true">
> <column name="`dtsadditionalpaymentst_id`" not-null="true"
> unique="false"/>
> </key>
> <list-index column="`dtsadditionalpayments_idx`"/>
> <element type="java.lang.String"/>
> </list>
> <list name="paymentConditionDescription" lazy="true"
> cascade="all,delete-orphan">
> <key update="true">
> <column name="`dtsadditionalpaymentst_id`" not-null="true"
> unique="false"/>
> </key>
> <list-index column="`dtsadditionalpayments_idx`"/>
> <element type="java.lang.String"/>
> </list>
> </class>
> ......
> <joined-subclass
> name=" customs.ru.information.customs.documents.dt.sout._3._0._1.im pl.DTSoutTypeImpl "
> entity-name="DTSoutType" abstract="false" lazy="false" extends="BaseDocType"
> table="`dtsouttype`">
> <meta attribute="eclassName">DTSoutType</meta>
> <meta
> attribute="epackage">urn:customs.ru:Information:CustomsDocuments:DTSout:3.0.1 </meta>
> <many-to-one name="dTSAdditionalPayments"
> entity-name="DTSAdditionalPaymentsType" cascade="all" lazy="false"
> insert="true" update="true" not-null="false">
> <column not-null="false" unique="false"
> name="`dtsadditionalpaymentst_id`"/>
> </many-to-one>
> ....
> </joined-subclass>
> ....
>
>
>
>
>
>


--

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] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #608765 is a reply to message #90047] Tue, 17 July 2007 12:43 Go to previous message
Roman Bliznets is currently offline Roman BliznetsFriend
Messages: 75
Registered: July 2009
Member
Ok, I'm attachnew hbm, old hbm and old persistence...
:)


Re: [Teneo] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #608766 is a reply to message #90063] Tue, 17 July 2007 12:47 Go to previous message
Roman Bliznets is currently offline Roman BliznetsFriend
Messages: 75
Registered: July 2009
Member
entirely foghot, archive description:
persistence.xml - old persistence
hbm.xml - it old hbm
hbm1.xml - it new hbm
Re: [Teneo] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #608770 is a reply to message #90077] Tue, 17 July 2007 14:51 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Thanks, I noticed the following differences:
- the persistence.xml did not seem to be picked up (at least not for the join tables)
- Teneo now adds a column tag to a key (this is probably were your exception comes from, although my
testcases don't get this exception)
- Teneo does not recognize your date fields as such (they are mapped as strings)
- Teneo adds a scale="0" to numeric columns

Can you send me the ecore file or if that is easier the model project? I can analyze why the
differences occur and repair this (if relevant).

Which options do you use to generate the hbm's?

gr. Martin

wolf_roma wrote:
> entirely foghot, archive description:
> persistence.xml - old persistence
> hbm.xml - it old hbm
> hbm1.xml - it new hbm
>
>


--

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] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #608780 is a reply to message #90137] Wed, 18 July 2007 07:42 Go to previous message
Roman Bliznets is currently offline Roman BliznetsFriend
Messages: 75
Registered: July 2009
Member
Hello.
1. Scale=0 - I a bit changed code for generation numeric filed: if exist
precision attribute always adding scale attribute (doesn't matter scale
contain default value or not). It fix same bug but I don't know whose its
bug (hibernate or teneo or mine or etc :))))) )
--- Most likely, it's hibernate bug and I don't post its in this
forum(news).
2. Ecore files: I attached their previous in 3th post (model.rar)
3. I used persistence.xml before, with this bug it useless
Re: [Teneo] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #608781 is a reply to message #90288] Wed, 18 July 2007 07:46 Go to previous message
Roman Bliznets is currently offline Roman BliznetsFriend
Messages: 75
Registered: July 2009
Member
Create datastore...

public SessionFactory getSessionFactory() {
if(sessionFactory==null){
PropertyConfigurator.configure("log4j.properties");
// create the HbDataStore
hbds = (HbDataStore)HbHelper.INSTANCE.createRegisterDataStore("mySF ");

final Properties props = new Properties();
props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
props.setProperty(Environment.USER, "root");
props.setProperty(Environment.URL, "jdbc:mysql://localhost/test");
props.setProperty(Environment.PASS, "rootpassword");
props.setProperty(Environment.DIALECT,
org.hibernate.dialect.MySQLDialect.class.getName());
props.setProperty(Environment.SHOW_SQL, "true");
// props.setProperty(Environment.HBM2DDL_AUTO, "update");
hbds.setHibernateProperties(props);

final Properties persisence=new Properties();
persisence.put(PersistenceOptions.JOIN_TABLE_NAMING_STRATEGY , "ejb3");
// persisence.put(PersistenceOptions.UPDATE_SCHEMA, "true");
persisence.put(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH, "25");
persisence.put(PersistenceOptions.INHERITANCE_MAPPING, "JOINED");
persisence.put(PersistenceOptions.PERSISTENCE_XML , "persistence.xml");
// persisence.put(PersistenceOptions.JOIN_COLUMN_NAMING_STRATEG Y,
"unique");
hbds.setPersistenceProperties(persisence);

// sets its epackages stored in this datastore
EPackage[] packages = new EPackage[]{_1Package.eINSTANCE,
_0Package.eINSTANCE,
customs.ru.common.aggregate.types._3._0._1._1Package.eINSTAN CE,
customs.ru.common.leaf.types._3._0._1._1Package.eINSTANCE,
customs.ru.esad.common.aggregate.types._3._0._1._1Package.eI NSTANCE,
customs.ru.esad.common.leaf.types._3._0._1._1Package.eINSTAN CE,
customs.ru.information.customs.documents.dt.sout._3._0._1._1 Package.eINSTANCE,
customs.ru.esaddts.common.aggregate.types._3._0._1._1Package .eINSTANCE,
customs.ru.ekts.common.aggregate.types._3._0._1._1Package.eI NSTANCE,
customs.ru.information.customs.documents.kt.sout._3._0._1._1 Package.eINSTANCE};
hbds.setEPackages(packages);

// initialize, also creates the database tables
hbds.initialize();
//take xml mapping into file (for debug)
writeMappingXML();


sessionFactory = hbds.getSessionFactory();
}
return sessionFactory;
}
Re: [Teneo] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #608783 is a reply to message #90301] Wed, 18 July 2007 09:45 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Thanks, yes I found the ecores.

>> Scale
The scale is read from the annotation meta data (fractionDigits), this should be okay.

>> Different Date mapping
It was the other way around the latest Teneo release now correctly identifies the date types,
therefore it does not use typedef's in the top of the hbm anymore. This also means however that the
mapping to the database has changed (it uses a date column instead of a string column).

>> The Exception
I tested this and the exception was caused by the following bug (or feature):
The latest release of Teneo now also computes the table name for list of primitive types. This table
name computation also does truncation if the name is too long (according to the options).
The problem with truncation logic is that it can result in non-unique naming (as the unique part is
truncated away).
This resulted in a eclass and a list of primitive string to be placed in the same table. You can
search the new hbm for the text table="`dtsadditionalpaymentstype`" and then you will see it appear
twice.
The primitive list causes this table to have two columns in the pk (the id and the idx).

I solved this by changing the truncation logic (there was a bug in it actually which caused it to
truncate away the wrong part). This will be in the next build.

Note that the new join table naming logic for primitive lists means that the generated hbm is not
backward compatible with the old db schema (only if the names are too long). So you need to use
jointable annotations to force Teneo to use the old tablenames (or transfer to a new db-schema).

Btw, the latest Teneo release offers an easier method to extend or override the sql naming strategy
(see extensions on the elver.org website).

gr. Martin


wolf_roma wrote:
> Create datastore...
>
> public SessionFactory getSessionFactory() {
> if(sessionFactory==null){
> PropertyConfigurator.configure("log4j.properties");
> // create the HbDataStore
> hbds = (HbDataStore)HbHelper.INSTANCE.createRegisterDataStore("mySF ");
>
> final Properties props = new Properties();
> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
> props.setProperty(Environment.USER, "root");
> props.setProperty(Environment.URL, "jdbc:mysql://localhost/test");
> props.setProperty(Environment.PASS, "rootpassword");
> props.setProperty(Environment.DIALECT,
> org.hibernate.dialect.MySQLDialect.class.getName());
> props.setProperty(Environment.SHOW_SQL, "true");
> // props.setProperty(Environment.HBM2DDL_AUTO, "update");
> hbds.setHibernateProperties(props);
>
> final Properties persisence=new Properties();
> persisence.put(PersistenceOptions.JOIN_TABLE_NAMING_STRATEGY , "ejb3");
> // persisence.put(PersistenceOptions.UPDATE_SCHEMA, "true");
> persisence.put(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH, "25");
> persisence.put(PersistenceOptions.INHERITANCE_MAPPING, "JOINED");
> persisence.put(PersistenceOptions.PERSISTENCE_XML , "persistence.xml");
> // persisence.put(PersistenceOptions.JOIN_COLUMN_NAMING_STRATEG Y,
> "unique");
> hbds.setPersistenceProperties(persisence);
>
> // sets its epackages stored in this datastore
> EPackage[] packages = new EPackage[]{_1Package.eINSTANCE,
> _0Package.eINSTANCE,
> customs.ru.common.aggregate.types._3._0._1._1Package.eINSTAN CE,
> customs.ru.common.leaf.types._3._0._1._1Package.eINSTANCE,
> customs.ru.esad.common.aggregate.types._3._0._1._1Package.eI NSTANCE,
> customs.ru.esad.common.leaf.types._3._0._1._1Package.eINSTAN CE,
> customs.ru.information.customs.documents.dt.sout._3._0._1._1 Package.eINSTANCE,
> customs.ru.esaddts.common.aggregate.types._3._0._1._1Package .eINSTANCE,
> customs.ru.ekts.common.aggregate.types._3._0._1._1Package.eI NSTANCE,
> customs.ru.information.customs.documents.kt.sout._3._0._1._1 Package.eINSTANCE};
> hbds.setEPackages(packages);
>
> // initialize, also creates the database tables
> hbds.initialize();
> //take xml mapping into file (for debug)
> writeMappingXML();
>
>
> sessionFactory = hbds.getSessionFactory();
> }
> return sessionFactory;
> }
>
>


--

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] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #608785 is a reply to message #90331] Wed, 18 July 2007 10:26 Go to previous message
Roman Bliznets is currently offline Roman BliznetsFriend
Messages: 75
Registered: July 2009
Member
Thanks.
Where bug fix in next release or next build?
When will the new build be?
Re: [Teneo] PersistenceOptions.JOIN_COLUMN_NAMING_STRATEGY [message #608789 is a reply to message #90362] Wed, 18 July 2007 11:27 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Build and release is the same for Teneo, I hope to do a new build today, otherwise it will be tomorrow.

gr. Martin

wolf_roma wrote:
> Thanks.
> Where bug fix in next release or next build?
> When will the new build be?
>
>
>
>


--

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:problem with initialzing jpoxDataStore(emf+teneo+derby)
Next Topic:Generating JDO outside of ecilpse
Goto Forum:
  


Current Time: Mon Oct 03 08:33:51 GMT 2022

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

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

Back to the top