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 |
Roman Bliznets 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 |
Martin Taal 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 #90301 is a reply to message #90288] |
Wed, 18 July 2007 07:46 |
Roman Bliznets 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 |
Martin Taal 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 #608762 is a reply to message #90001] |
Tue, 17 July 2007 11:45 |
Martin Taal 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 #608781 is a reply to message #90288] |
Wed, 18 July 2007 07:46 |
Roman Bliznets 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 |
Martin Taal 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
|
|
| | |
Goto Forum:
Current Time: Thu Dec 12 02:13:09 GMT 2024
Powered by FUDForum. Page generated in 0.04401 seconds
|