Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Teneo] Problem saving EPackage loaded from database
[Teneo] Problem saving EPackage loaded from database [message #426338] Fri, 26 December 2008 21:34 Go to next message
Eclipse UserFriend
Originally posted by: mduduzi.keswa.isizwe.com

Happy Holidays Everyone!
I'm storing all generated Epackages in the database. Here's the the
scenario (in separate junit test cases) - what am I doing wrong?:

1. Store EcorePackage.eINSTANCE in the database:
1.1 session.save(EcorePackage.eINSTANCE);

RESULT: Successful

2. Create a new EPackage 'SchoolBook':
2.1 HbDataStore hds = DbUtil.createHBDS(new
EPackage[]{EcorePackage.eINSTANCE});
2.2 Query qry = session.createQuery("from EPackage where
name='ecore'");
2.3 List<EPackage> pkgs = qry.list();
2.4 EPackage ecorePkg = pkgs.get(0);
2.5 tx.begin();
2.6 session.save(schoolPackage);
2.7 tx.commit();
2.8 session.close();

RESULT: Successful (with an entry in 'ecore_eobject' table of the new
EPackage)

3. Add an EClass to the existing 'SchoolBook' package (epackage is
EcorePackage.eINSTANCE):
3.1 HbDataStore hds = DbUtil.createHBDS(new
EPackage[]{EcorePackage.eINSTANCE});
3.2 SessionFactory sessionFactory = hds.getSessionFactory();
3.3 tx.begin();
3.4 Query qry = session.createQuery("from EPackage where name='ecore'");
3.5 List<EPackage> pkgs = qry.list();
3.6 EPackage ecorePkg = pkgs.get(0);
3.7 Registry.INSTANCE.put(ecorePkg.getNsURI(), ecorePkg);
3.8 qry = session.createQuery("from EPackage where
name='SchoolPackage'");
3.9 pkgs = qry.list();
3.10 EPackage schPkg = pkgs.get(0);
3.11 Registry.INSTANCE.put(schPkg.getNsURI(), schPkg);
3.12 hds.setEPackages(new EPackage[]{ecorePkg,schPkg});
3.11 hds.initialize();
3.12 EClass schoolBookEClass = efactory.createEClass();
3.13 schoolBookEClass.setName("SchoolBook");
// create a new attribute for this EClass
3.14 EAttribute level = efactory.createEAttribute();
3.15 level.setName("level");
3.16 level.setEType(epackage.getEInt());
3.17 schoolBookEClass.getEStructuralFeatures().add(level);
3.18 session.save(level);
3.19 session.save(schoolBookEClass);
3.20 schPkg.getEClassifiers().add(schoolBookEClass);
3.21 session.save(schPkg);
3.22 tx.commit();
3.23 session.close();

RESULT:
ERROR: org.hibernate.TransientObjectException: object references an
unsaved transient instance - save the transient instance before
flushing: EClassifier

TRACE:
INFO: indexes: [primary, fk5cd8f2424d8f171]
Dec 26, 2008 4:29:07 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
getTableMetadata
INFO: table not found: eobject
Dec 26, 2008 4:29:07 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
SEVERE: Unsuccessful: alter table `eobject` add index
emodelelement_eannotations (`eannotation_emodelelement_e_id`), add
constraint emodelelement_eannotations foreign key
(`eannotation_emodelelement_e_id`) references `eobject` (e_id)
Dec 26, 2008 4:29:07 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
SEVERE: Can't create table '.\solutionassembly\#sql-2ec_4d.frm' (errno: 121)

============ MANY MORE 'SEVERE' ERRORS IN BETWEEN =====================
Dec 26, 2008 4:29:08 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
SEVERE: Can't create table '.\solutionassembly\#sql-2ec_4d.frm' (errno: 121)
Dec 26, 2008 4:29:08 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: schema update complete
Re: [Teneo] Problem saving EPackage loaded from database [message #426339 is a reply to message #426338] Sat, 27 December 2008 00:56 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mdu,
I see that you reinitialize the datastore in step 3.11 but do not get a new session. Does the
exception occur if you remove these two lines:
> 3.12 hds.setEPackages(new EPackage[]{ecorePkg,schPkg});
> 3.11 hds.initialize();

Then next I would put a breakpoint at the location where hibernate throws the exception and then
check which instance it fails on.

gr. Martin

Mdu wrote:
> Happy Holidays Everyone!
> I'm storing all generated Epackages in the database. Here's the the
> scenario (in separate junit test cases) - what am I doing wrong?:
>
> 1. Store EcorePackage.eINSTANCE in the database:
> 1.1 session.save(EcorePackage.eINSTANCE);
>
> RESULT: Successful
>
> 2. Create a new EPackage 'SchoolBook':
> 2.1 HbDataStore hds = DbUtil.createHBDS(new
> EPackage[]{EcorePackage.eINSTANCE});
> 2.2 Query qry = session.createQuery("from EPackage where
> name='ecore'");
> 2.3 List<EPackage> pkgs = qry.list();
> 2.4 EPackage ecorePkg = pkgs.get(0);
> 2.5 tx.begin();
> 2.6 session.save(schoolPackage);
> 2.7 tx.commit();
> 2.8 session.close();
>
> RESULT: Successful (with an entry in 'ecore_eobject' table of the new
> EPackage)
>
> 3. Add an EClass to the existing 'SchoolBook' package (epackage is
> EcorePackage.eINSTANCE):
> 3.1 HbDataStore hds = DbUtil.createHBDS(new
> EPackage[]{EcorePackage.eINSTANCE});
> 3.2 SessionFactory sessionFactory = hds.getSessionFactory();
> 3.3 tx.begin();
> 3.4 Query qry = session.createQuery("from EPackage where name='ecore'");
> 3.5 List<EPackage> pkgs = qry.list();
> 3.6 EPackage ecorePkg = pkgs.get(0);
> 3.7 Registry.INSTANCE.put(ecorePkg.getNsURI(), ecorePkg);
> 3.8 qry = session.createQuery("from EPackage where
> name='SchoolPackage'");
> 3.9 pkgs = qry.list();
> 3.10 EPackage schPkg = pkgs.get(0);
> 3.11 Registry.INSTANCE.put(schPkg.getNsURI(), schPkg);
> 3.12 hds.setEPackages(new EPackage[]{ecorePkg,schPkg});
> 3.11 hds.initialize();
> 3.12 EClass schoolBookEClass = efactory.createEClass();
> 3.13 schoolBookEClass.setName("SchoolBook");
> // create a new attribute for this EClass
> 3.14 EAttribute level = efactory.createEAttribute();
> 3.15 level.setName("level");
> 3.16 level.setEType(epackage.getEInt());
> 3.17 schoolBookEClass.getEStructuralFeatures().add(level);
> 3.18 session.save(level);
> 3.19 session.save(schoolBookEClass);
> 3.20 schPkg.getEClassifiers().add(schoolBookEClass);
> 3.21 session.save(schPkg);
> 3.22 tx.commit();
> 3.23 session.close();
>
> RESULT:
> ERROR: org.hibernate.TransientObjectException: object references an
> unsaved transient instance - save the transient instance before
> flushing: EClassifier
>
> TRACE:
> INFO: indexes: [primary, fk5cd8f2424d8f171]
> Dec 26, 2008 4:29:07 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
> getTableMetadata
> INFO: table not found: eobject
> Dec 26, 2008 4:29:07 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
> SEVERE: Unsuccessful: alter table `eobject` add index
> emodelelement_eannotations (`eannotation_emodelelement_e_id`), add
> constraint emodelelement_eannotations foreign key
> (`eannotation_emodelelement_e_id`) references `eobject` (e_id)
> Dec 26, 2008 4:29:07 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
> SEVERE: Can't create table '.\solutionassembly\#sql-2ec_4d.frm' (errno:
> 121)
>
> ============ MANY MORE 'SEVERE' ERRORS IN BETWEEN =====================
> Dec 26, 2008 4:29:08 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
> SEVERE: Can't create table '.\solutionassembly\#sql-2ec_4d.frm' (errno:
> 121)
> Dec 26, 2008 4:29:08 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
> INFO: schema update complete


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
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] Problem saving EPackage loaded from database [message #426340 is a reply to message #426339] Sat, 27 December 2008 01:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mduduzi.keswa.isizwe.com

Hi Martin - thanks again for your time. See my imbedded comments below:
Martin Taal wrote:
> Hi Mdu,
> I see that you reinitialize the datastore in step 3.11 but do not get a
> new session. Does the exception occur if you remove these two lines:
> > 3.12 hds.setEPackages(new EPackage[]{ecorePkg,schPkg});
> > 3.11 hds.initialize();
I did remove these two lines - but I still get the same error.
>
> Then next I would put a breakpoint at the location where hibernate
> throws the exception and then check which instance it fails on.
By instance, what are you refering to? epackage or something else? And
to able to do this, do I needd access to Hibernate source code?
>
> gr. Martin
>
> Mdu wrote:
>> Happy Holidays Everyone!
>> I'm storing all generated Epackages in the database. Here's the the
>> scenario (in separate junit test cases) - what am I doing wrong?:
>>
>> 1. Store EcorePackage.eINSTANCE in the database:
>> 1.1 session.save(EcorePackage.eINSTANCE);
>>
>> RESULT: Successful
>>
>> 2. Create a new EPackage 'SchoolBook':
>> 2.1 HbDataStore hds = DbUtil.createHBDS(new
>> EPackage[]{EcorePackage.eINSTANCE});
>> 2.2 Query qry = session.createQuery("from EPackage where
>> name='ecore'");
>> 2.3 List<EPackage> pkgs = qry.list();
>> 2.4 EPackage ecorePkg = pkgs.get(0); 2.5 tx.begin();
>> 2.6 session.save(schoolPackage); 2.7 tx.commit();
>> 2.8 session.close();
>>
>> RESULT: Successful (with an entry in 'ecore_eobject' table of the new
>> EPackage)
>>
>> 3. Add an EClass to the existing 'SchoolBook' package (epackage is
>> EcorePackage.eINSTANCE):
>> 3.1 HbDataStore hds = DbUtil.createHBDS(new
>> EPackage[]{EcorePackage.eINSTANCE});
>> 3.2 SessionFactory sessionFactory = hds.getSessionFactory();
>> 3.3 tx.begin(); 3.4 Query qry = session.createQuery("from
>> EPackage where name='ecore'");
>> 3.5 List<EPackage> pkgs = qry.list();
>> 3.6 EPackage ecorePkg = pkgs.get(0); 3.7
>> Registry.INSTANCE.put(ecorePkg.getNsURI(), ecorePkg);
>> 3.8 qry = session.createQuery("from EPackage where
>> name='SchoolPackage'");
>> 3.9 pkgs = qry.list();
>> 3.10 EPackage schPkg = pkgs.get(0);
>> 3.11 Registry.INSTANCE.put(schPkg.getNsURI(), schPkg);
>> 3.12 hds.setEPackages(new EPackage[]{ecorePkg,schPkg});
>> 3.11 hds.initialize();
>> 3.12 EClass schoolBookEClass = efactory.createEClass();
>> 3.13 schoolBookEClass.setName("SchoolBook"); // create a
>> new attribute for this EClass
>> 3.14 EAttribute level = efactory.createEAttribute();
>> 3.15 level.setName("level");
>> 3.16 level.setEType(epackage.getEInt());
>> 3.17
>> schoolBookEClass.getEStructuralFeatures().add(level);
>> 3.18 session.save(level); 3.19
>> session.save(schoolBookEClass); 3.20
>> schPkg.getEClassifiers().add(schoolBookEClass);
>> 3.21 session.save(schPkg);
>> 3.22 tx.commit();
>> 3.23 session.close();
>> RESULT:
>> ERROR: org.hibernate.TransientObjectException: object references an
>> unsaved transient instance - save the transient instance before
>> flushing: EClassifier
>>
>> TRACE:
>> INFO: indexes: [primary, fk5cd8f2424d8f171]
>> Dec 26, 2008 4:29:07 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
>> getTableMetadata
>> INFO: table not found: eobject
>> Dec 26, 2008 4:29:07 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
>> SEVERE: Unsuccessful: alter table `eobject` add index
>> emodelelement_eannotations (`eannotation_emodelelement_e_id`), add
>> constraint emodelelement_eannotations foreign key
>> (`eannotation_emodelelement_e_id`) references `eobject` (e_id)
>> Dec 26, 2008 4:29:07 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
>> SEVERE: Can't create table '.\solutionassembly\#sql-2ec_4d.frm'
>> (errno: 121)
>>
>> ============ MANY MORE 'SEVERE' ERRORS IN BETWEEN =====================
>> Dec 26, 2008 4:29:08 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
>> SEVERE: Can't create table '.\solutionassembly\#sql-2ec_4d.frm'
>> (errno: 121)
>> Dec 26, 2008 4:29:08 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
>> INFO: schema update complete
>
>
Re: [Teneo] Problem saving EPackage loaded from database - more info [message #426341 is a reply to message #426339] Sat, 27 December 2008 02:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mduduzi.keswa.isizwe.com

Hi Martin,
I put a breakpoint in hibernate and the exception is coming from
ForeignKey.class in code:
/**
* Return the identifier of the persistent or transient object, or throw
* an exception if the instance is "unsaved"
*
* Used by OneToOneType and ManyToOneType to determine what id value
should
* be used for an object that may or may not be associated with the
session.
* This does a "best guess" using any/all info available to use (not
just the
* EntityEntry).
*/
public static Serializable getEntityIdentifierIfNotUnsaved(
final String entityName,
final Object object,
final SessionImplementor session)
throws HibernateException {
if ( object == null ) {
return null;
}
else {
Serializable id = session.getContextEntityIdentifier( object );
if ( id == null ) {
// context-entity-identifier returns null explicitly if the entity
// is not associated with the persistence context; so make some
// deeper checks...
if ( isTransient(entityName, object, Boolean.FALSE, session) ) {
throw new TransientObjectException(
"object references an unsaved transient instance - save the
transient instance before flushing: " +
(entityName == null ? session.guessEntityName( object ) : entityName)
);
}
id = session.getEntityPersister( entityName, object ).getIdentifier(
object, session.getEntityMode() );
}
return id;
}
}



The only thing I can make sense of is that in the above method call
entityName is 'EClassifier' and object is an 'EDataTypeImpl' whose inner
type is 'EInt' - the type of the attribute 'level' in the example. I'm
lost as to why this fails since I have loaded and registered 'ecore'
epackage in steps 3.x.

Am I making the right calls at the right sequence in step 3?

Thanks and regards,
-Mdu
Martin Taal wrote:
> Hi Mdu,
> I see that you reinitialize the datastore in step 3.11 but do not get a
> new session. Does the exception occur if you remove these two lines:
> > 3.12 hds.setEPackages(new EPackage[]{ecorePkg,schPkg});
> > 3.11 hds.initialize();
>
> Then next I would put a breakpoint at the location where hibernate
> throws the exception and then check which instance it fails on.
>
> gr. Martin
>
> Mdu wrote:
>> Happy Holidays Everyone!
>> I'm storing all generated Epackages in the database. Here's the the
>> scenario (in separate junit test cases) - what am I doing wrong?:
>>
>> 1. Store EcorePackage.eINSTANCE in the database:
>> 1.1 session.save(EcorePackage.eINSTANCE);
>>
>> RESULT: Successful
>>
>> 2. Create a new EPackage 'SchoolBook':
>> 2.1 HbDataStore hds = DbUtil.createHBDS(new
>> EPackage[]{EcorePackage.eINSTANCE});
>> 2.2 Query qry = session.createQuery("from EPackage where
>> name='ecore'");
>> 2.3 List<EPackage> pkgs = qry.list();
>> 2.4 EPackage ecorePkg = pkgs.get(0); 2.5 tx.begin();
>> 2.6 session.save(schoolPackage); 2.7 tx.commit();
>> 2.8 session.close();
>>
>> RESULT: Successful (with an entry in 'ecore_eobject' table of the new
>> EPackage)
>>
>> 3. Add an EClass to the existing 'SchoolBook' package (epackage is
>> EcorePackage.eINSTANCE):
>> 3.1 HbDataStore hds = DbUtil.createHBDS(new
>> EPackage[]{EcorePackage.eINSTANCE});
>> 3.2 SessionFactory sessionFactory = hds.getSessionFactory();
>> 3.3 tx.begin(); 3.4 Query qry = session.createQuery("from
>> EPackage where name='ecore'");
>> 3.5 List<EPackage> pkgs = qry.list();
>> 3.6 EPackage ecorePkg = pkgs.get(0); 3.7
>> Registry.INSTANCE.put(ecorePkg.getNsURI(), ecorePkg);
>> 3.8 qry = session.createQuery("from EPackage where
>> name='SchoolPackage'");
>> 3.9 pkgs = qry.list();
>> 3.10 EPackage schPkg = pkgs.get(0);
>> 3.11 Registry.INSTANCE.put(schPkg.getNsURI(), schPkg);
>> 3.12 hds.setEPackages(new EPackage[]{ecorePkg,schPkg});
>> 3.11 hds.initialize();
>> 3.12 EClass schoolBookEClass = efactory.createEClass();
>> 3.13 schoolBookEClass.setName("SchoolBook"); // create a
>> new attribute for this EClass
>> 3.14 EAttribute level = efactory.createEAttribute();
>> 3.15 level.setName("level");
>> 3.16 level.setEType(epackage.getEInt());
>> 3.17
>> schoolBookEClass.getEStructuralFeatures().add(level);
>> 3.18 session.save(level); 3.19
>> session.save(schoolBookEClass); 3.20
>> schPkg.getEClassifiers().add(schoolBookEClass);
>> 3.21 session.save(schPkg);
>> 3.22 tx.commit();
>> 3.23 session.close();
>> RESULT:
>> ERROR: org.hibernate.TransientObjectException: object references an
>> unsaved transient instance - save the transient instance before
>> flushing: EClassifier
>>
>> TRACE:
>> INFO: indexes: [primary, fk5cd8f2424d8f171]
>> Dec 26, 2008 4:29:07 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
>> getTableMetadata
>> INFO: table not found: eobject
>> Dec 26, 2008 4:29:07 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
>> SEVERE: Unsuccessful: alter table `eobject` add index
>> emodelelement_eannotations (`eannotation_emodelelement_e_id`), add
>> constraint emodelelement_eannotations foreign key
>> (`eannotation_emodelelement_e_id`) references `eobject` (e_id)
>> Dec 26, 2008 4:29:07 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
>> SEVERE: Can't create table '.\solutionassembly\#sql-2ec_4d.frm'
>> (errno: 121)
>>
>> ============ MANY MORE 'SEVERE' ERRORS IN BETWEEN =====================
>> Dec 26, 2008 4:29:08 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
>> SEVERE: Can't create table '.\solutionassembly\#sql-2ec_4d.frm'
>> (errno: 121)
>> Dec 26, 2008 4:29:08 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
>> INFO: schema update complete
>
>
Re: [Teneo] Problem saving EPackage loaded from database - more info [message #426348 is a reply to message #426341] Mon, 29 December 2008 06:44 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mdu,
Should have seen this right away:
This exception is thrown because you did not pass the xmltypepackage (
org.eclipse.emf.ecore.xml.type.XMLTypePackage) to the datastore (in addition to the ecorepackage).

gr. Martin

Mdu wrote:
> Hi Martin,
> I put a breakpoint in hibernate and the exception is coming from
> ForeignKey.class in code:
> /**
> * Return the identifier of the persistent or transient object, or
> throw
> * an exception if the instance is "unsaved"
> *
> * Used by OneToOneType and ManyToOneType to determine what id value
> should
> * be used for an object that may or may not be associated with the
> session.
> * This does a "best guess" using any/all info available to use (not
> just the
> * EntityEntry).
> */
> public static Serializable getEntityIdentifierIfNotUnsaved(
> final String entityName,
> final Object object,
> final SessionImplementor session)
> throws HibernateException {
> if ( object == null ) {
> return null;
> }
> else {
> Serializable id = session.getContextEntityIdentifier( object );
> if ( id == null ) {
> // context-entity-identifier returns null explicitly if
> the entity
> // is not associated with the persistence context; so
> make some
> // deeper checks...
> if ( isTransient(entityName, object, Boolean.FALSE,
> session) ) {
> throw new TransientObjectException(
> "object references an unsaved transient
> instance - save the transient instance before flushing: " +
> (entityName == null ?
> session.guessEntityName( object ) : entityName)
> );
> }
> id = session.getEntityPersister( entityName, object
> ).getIdentifier( object, session.getEntityMode() );
> }
> return id;
> }
> }
>
>
>
> The only thing I can make sense of is that in the above method call
> entityName is 'EClassifier' and object is an 'EDataTypeImpl' whose inner
> type is 'EInt' - the type of the attribute 'level' in the example. I'm
> lost as to why this fails since I have loaded and registered 'ecore'
> epackage in steps 3.x.
>
> Am I making the right calls at the right sequence in step 3?
>
> Thanks and regards,
> -Mdu
> Martin Taal wrote:
>> Hi Mdu,
>> I see that you reinitialize the datastore in step 3.11 but do not get
>> a new session. Does the exception occur if you remove these two lines:
>> > 3.12 hds.setEPackages(new EPackage[]{ecorePkg,schPkg});
>> > 3.11 hds.initialize();
>>
>> Then next I would put a breakpoint at the location where hibernate
>> throws the exception and then check which instance it fails on.
>>
>> gr. Martin
>>
>> Mdu wrote:
>>> Happy Holidays Everyone!
>>> I'm storing all generated Epackages in the database. Here's the the
>>> scenario (in separate junit test cases) - what am I doing wrong?:
>>>
>>> 1. Store EcorePackage.eINSTANCE in the database:
>>> 1.1 session.save(EcorePackage.eINSTANCE);
>>>
>>> RESULT: Successful
>>>
>>> 2. Create a new EPackage 'SchoolBook':
>>> 2.1 HbDataStore hds = DbUtil.createHBDS(new
>>> EPackage[]{EcorePackage.eINSTANCE});
>>> 2.2 Query qry = session.createQuery("from EPackage where
>>> name='ecore'");
>>> 2.3 List<EPackage> pkgs = qry.list();
>>> 2.4 EPackage ecorePkg = pkgs.get(0); 2.5 tx.begin();
>>> 2.6 session.save(schoolPackage); 2.7 tx.commit();
>>> 2.8 session.close();
>>>
>>> RESULT: Successful (with an entry in 'ecore_eobject' table of the new
>>> EPackage)
>>>
>>> 3. Add an EClass to the existing 'SchoolBook' package (epackage is
>>> EcorePackage.eINSTANCE):
>>> 3.1 HbDataStore hds = DbUtil.createHBDS(new
>>> EPackage[]{EcorePackage.eINSTANCE});
>>> 3.2 SessionFactory sessionFactory = hds.getSessionFactory();
>>> 3.3 tx.begin(); 3.4 Query qry = session.createQuery("from
>>> EPackage where name='ecore'");
>>> 3.5 List<EPackage> pkgs = qry.list();
>>> 3.6 EPackage ecorePkg = pkgs.get(0); 3.7
>>> Registry.INSTANCE.put(ecorePkg.getNsURI(), ecorePkg);
>>> 3.8 qry = session.createQuery("from EPackage where
>>> name='SchoolPackage'");
>>> 3.9 pkgs = qry.list();
>>> 3.10 EPackage schPkg = pkgs.get(0);
>>> 3.11 Registry.INSTANCE.put(schPkg.getNsURI(), schPkg);
>>> 3.12 hds.setEPackages(new EPackage[]{ecorePkg,schPkg});
>>> 3.11 hds.initialize();
>>> 3.12 EClass schoolBookEClass = efactory.createEClass();
>>> 3.13 schoolBookEClass.setName("SchoolBook"); // create a
>>> new attribute for this EClass
>>> 3.14 EAttribute level = efactory.createEAttribute();
>>> 3.15 level.setName("level");
>>> 3.16 level.setEType(epackage.getEInt());
>>> 3.17
>>> schoolBookEClass.getEStructuralFeatures().add(level);
>>> 3.18 session.save(level); 3.19
>>> session.save(schoolBookEClass); 3.20
>>> schPkg.getEClassifiers().add(schoolBookEClass);
>>> 3.21 session.save(schPkg);
>>> 3.22 tx.commit();
>>> 3.23 session.close();
>>> RESULT:
>>> ERROR: org.hibernate.TransientObjectException: object references
>>> an unsaved transient instance - save the transient instance before
>>> flushing: EClassifier
>>>
>>> TRACE:
>>> INFO: indexes: [primary, fk5cd8f2424d8f171]
>>> Dec 26, 2008 4:29:07 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata
>>> getTableMetadata
>>> INFO: table not found: eobject
>>> Dec 26, 2008 4:29:07 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
>>> SEVERE: Unsuccessful: alter table `eobject` add index
>>> emodelelement_eannotations (`eannotation_emodelelement_e_id`), add
>>> constraint emodelelement_eannotations foreign key
>>> (`eannotation_emodelelement_e_id`) references `eobject` (e_id)
>>> Dec 26, 2008 4:29:07 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
>>> SEVERE: Can't create table '.\solutionassembly\#sql-2ec_4d.frm'
>>> (errno: 121)
>>>
>>> ============ MANY MORE 'SEVERE' ERRORS IN BETWEEN =====================
>>> Dec 26, 2008 4:29:08 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
>>> SEVERE: Can't create table '.\solutionassembly\#sql-2ec_4d.frm'
>>> (errno: 121)
>>> Dec 26, 2008 4:29:08 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
>>> INFO: schema update complete
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
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:Copyright text isn't regenerated
Next Topic:How to read the classes of dependency libraries
Goto Forum:
  


Current Time: Sat May 30 09:45:16 GMT 2020

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

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

Back to the top