Skip to main content



      Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] possible bug: object references an unsaved transient instance
[Teneo] possible bug: object references an unsaved transient instance [message #1702340] Tue, 21 July 2015 11:48 Go to next message
Eclipse UserFriend
Hello all!

I have got this famous, but unexpected exception:
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: test.Embedded

My object model:

Emfatic:
class Embedded2 {
attr String[1] name;
}

class Embedded {
attr String[1] name;
val Embedded2[1] value;
}

class Table {
attr String[1] name;
val Embedded[*] content;
}

Now, persist root object Table, create Embedded and Embedded2, try to merge and got the exception, pointed above.

My setup:
-----
hibernate:
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL9Dialect</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.url">jdbc:postgresql://192.168.2.75:5432/teneo</property>
<property name="hibernate.globally_quoted_identifiers">true</property>
<property name="default_entity_mode">dynamic-map</property>

-----
teneo:
properties.put(PersistenceOptions.MAP_DOCUMENT_ROOT, "true");
properties.put(PersistenceOptions.AUTO_ADD_REFERENCED_EPACKAGES, "true");
properties.put(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH, "63");
properties.put(PersistenceOptions.SQL_NAME_ESCAPE_CHARACTER, "");
properties.put(PersistenceOptions.CASCADE_POLICY_ON_NON_CONTAINMENT, "REFRESH");
properties.put(PersistenceOptions.FORCE_LAZY, "true");

-----
Generated mapping:
<class entity-name="test.Embedded2" abstract="false" lazy="true" discriminator-value="test.Embedded2" table="test_embedded2">
<meta attribute="eclassName" inherit="false">Embedded2</meta>
<meta attribute="epackage" inherit="false">test</meta>
<id type="long" name="e_id" column="e_id" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler">
<meta attribute="syntheticId" inherit="false">true</meta>
<generator class="native"/>
</id>
<discriminator type="string">
<column name="dtype" index="test_embedded2dtype" length="255" not-null="true"/>
</discriminator>
<version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler">
<meta attribute="syntheticVersion" inherit="false">true</meta>
</version>
<property name="name" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String">
<column not-null="true" unique="false" name="name"/>
</property>
</class>
<class entity-name="test.Embedded" abstract="false" lazy="true" discriminator-value="test.Embedded" table="test_embedded">
<meta attribute="eclassName" inherit="false">Embedded</meta>
<meta attribute="epackage" inherit="false">test</meta>
<id type="long" name="e_id" column="e_id" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler">
<meta attribute="syntheticId" inherit="false">true</meta>
<generator class="native"/>
</id>
<discriminator type="string">
<column name="dtype" index="test_embeddeddtype" length="255" not-null="true"/>
</discriminator>
<version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler">
<meta attribute="syntheticVersion" inherit="false">true</meta>
</version>
<property name="name" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String">
<column not-null="true" unique="false" name="name"/>
</property>
<many-to-one name="value" entity-name="test.Embedded2" lazy="proxy" cascade="all" foreign-key="test_embedded_value" insert="true" update="true" not-null="true" unique="true">
<column not-null="true" unique="false" name="embedded2_value_e_id"/>
</many-to-one>
</class>
<class entity-name="test.Table" abstract="false" lazy="true" discriminator-value="test.Table" table="test_table">
<meta attribute="eclassName" inherit="false">Table</meta>
<meta attribute="epackage" inherit="false">test</meta>
<id type="long" name="e_id" column="e_id" access="org.eclipse.emf.teneo.hibernate.mapping.identifier.IdentifierPropertyHandler">
<meta attribute="syntheticId" inherit="false">true</meta>
<generator class="native"/>
</id>
<discriminator type="string">
<column name="dtype" index="test_tabledtype" length="255" not-null="true"/>
</discriminator>
<version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler">
<meta attribute="syntheticVersion" inherit="false">true</meta>
</version>
<property name="name" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String">
<column not-null="true" unique="false" name="name"/>
</property>
<list name="content" lazy="true" cascade="all,delete-orphan">
<key foreign-key="test_table_content_key" update="true">
<column name="table_content_e_id" unique="false"/>
</key>
<list-index column="table_content_idx"/>
<one-to-many entity-name="test.Embedded"/>
</list>
</class>

Any hints, please?

[Updated on: Tue, 21 July 2015 11:58] by Moderator

Re: [Teneo] possible bug: object references an unsaved transient instance [message #1702380 is a reply to message #1702340] Tue, 21 July 2015 18:30 Go to previous messageGo to next message
Eclipse UserFriend
I made some investigations in the debugger to see, whats going on here.

1. Table object has its e_id, Embedded and Embedded2 are in transient state.
2. Merge Table object.
3. Hibernate cascade merge to Embedded and then to Embedded2.
4. Hibarnate trying propagate cascade merge back to Embedded and failed with exception.

Step 4 here is the root of the problem. Embedded2 references to Embedded with special, teneo specific, association EContainerUserType. Then hibernate ask this association about its direction (getForeignKeyDirection) it answers ForeignKeyDirection.FOREIGN_KEY_FROM_PARENT (this is not true in that case) and hibernate decide to propagate merge back to Embedded object.

If we intercept this process in the debugger and force to return from getForeignKeyDirection anything but FOREIGN_KEY_FROM_PARENT , merge process ends with success.
Re: [Teneo] possible bug: object references an unsaved transient instance [message #1702553 is a reply to message #1702380] Thu, 23 July 2015 03:59 Go to previous messageGo to next message
Eclipse UserFriend
Hi Oleg,
Can you enter a bugzilla for it? It would be great if you can attach a small example model so there is no confusion on
this. If you can add some pseudo code which shows what you do to reproduce the issue then I can move that into a test case.

And also which teneo/hibernate version you are running/testing.

gr. Martin

On 22-07-15 00:30, Oleg Orlov wrote:
> I made some investigations in the debugger to see, whats going on here.
>
> 1. Table object has its e_id, Embedded and Embedded2 are in transient state.
> 2. Merge Table object.
> 3. Hibernate cascade merge to Embedded and then to Embedded2.
> 4. Hibarnate trying propagate cascade merge back to Embedded and failed with exception.
>
> Step 4 here is the root of the problem. Embedded2 references to Embedded with special, teneo specific, association
> EContainerUserType. Then hibernate ask this association about its direction (getForeignKeyDirection) it answers
> ForeignKeyDirection.FOREIGN_KEY_FROM_PARENT (this is not true in that case) and hibernate decide to propagate merge back
> to Embedded object.
>
> If we intercept this process in the debugger and force to return from getForeignKeyDirection anything but
> FOREIGN_KEY_FROM_PARENT , merge process ends with success.


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Teneo] possible bug: object references an unsaved transient instance [message #1702603 is a reply to message #1702553] Thu, 23 July 2015 09:26 Go to previous messageGo to next message
Eclipse UserFriend
Hi Martin.
We use 2.1.0.v201505242010
Ill report to bugzilla as you suggested.
Re: [Teneo] possible bug: object references an unsaved transient instance [message #1702620 is a reply to message #1702603] Thu, 23 July 2015 10:44 Go to previous message
Eclipse UserFriend
Done.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=473413
Ive attached small java code to reproduce my case.
Previous Topic:[Teneo] two small enhancements in SerializableDynamicEObjectImpl
Next Topic:Problem with installation of ecore diagramm
Goto Forum:
  


Current Time: Wed Jul 23 11:03:17 EDT 2025

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

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

Back to the top