|
|
Re: Teneo + EcoreUtil.Copier: Wrong ID ..? [message #544005 is a reply to message #543968] |
Thu, 01 July 2010 10:00 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Wolf,
Depending on the inheritance mapping strategy Hibernate stores objects of different types in one table. Then when
retrieving references (many-to-one) it checks that the retrieved object is indeed of the expected type. In your case
there is something wrong there.
Another reason can be that there are name clashes in ereferences names in different subclasses which are stored in the
same table and therefore are stored in the same column. Resulting in illegal references. Can this be the case in your
model that there are 2 subtypes which have ereferences with the same name?
Can you try with the option:
teneo.mapping.inheritance
set to the value:
JOINED
gr. Martin
On 07/01/2010 10:41 AM, Wolf Fischer wrote:
> I just tried several things: One was the use of the EcoreUtil.copyall
> Method (which yielded the same results), the other was taking the
> objects directly from the file resource and adding it to the db-resource
> without copying them. To my surprise, this way the elements still were
> being inserted into the DB and the original error remained, when opening
> the DB with the editor... So - why does hibernate have a problem with a
> structure that seems to be perfectly legitimate to the editor, if coming
> directly from the file?
--
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 + EcoreUtil.Copier: Wrong ID ..? [message #544171 is a reply to message #544015] |
Thu, 01 July 2010 21:30 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Wolf,
With single table inheritance, can you set a @JoinColumn(name='myuniquename') on one of the two ereferences to give it
another unique name.
gr. Martin
On 07/01/2010 01:14 PM, Wolf Fischer wrote:
> Hi Martin,
>
> Thanks for your answer!
> My standard mapping.inheritance was set to single. If i switch to
> "JOINED", i get the following exception:
> 0 [main] ERROR org.hibernate.util.JDBCExceptionReporter - Field 'dtype'
> doesn't have a default value
> org.hibernate.exception.GenericJDBCException: could not insert: [Domain]
> at org.hibernate.exception.SQLStateConverter.handledNonSpecific
> Exception(SQLStateConverter.java:126)
> at org.hibernate.exception.SQLStateConverter.convert(SQLStateCo
> nverter.java:114)
> at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExce
> ptionHelper.java:66)
> at org.hibernate.id.insert.AbstractReturningDelegate.performIns
> ert(AbstractReturningDelegate.java:64)
> at org.hibernate.persister.entity.AbstractEntityPersister.inser
> t(AbstractEntityPersister.java:2176)
> at org.hibernate.persister.entity.AbstractEntityPersister.inser
> t(AbstractEntityPersister.java:2656)
> at org.hibernate.action.EntityIdentityInsertAction.execute(Enti
> tyIdentityInsertAction.java:71)
> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:27 9)
> at org.hibernate.event.def.AbstractSaveEventListener.performSav
> eOrReplicate(AbstractSaveEventListener.java:321)
> at org.hibernate.event.def.AbstractSaveEventListener.performSav
> e(AbstractSaveEventListener.java:204)
> at org.hibernate.event.def.AbstractSaveEventListener.saveWithGe
> neratedId(AbstractSaveEventListener.java:130)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav
> eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:210)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent
> ityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per
> formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
> at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS
> aveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
> at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:535)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :527)
> at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :523)
> at org.eclipse.emf.teneo.hibernate.HbSessionWrapper.saveOrUpdat
> e(HbSessionWrapper.java:161)
> at org.eclipse.emf.teneo.hibernate.resource.HibernateResource.s
> aveResource(HibernateResource.java:351)
> at org.eclipse.emf.teneo.resource.StoreResource.save(StoreResou
> rce.java:405)
> at brms.helper.ImportFile2DB.convert(ImportFile2DB.java:125)
> at brms.helper.ImportFile2DB.main(ImportFile2DB.java:179)
> Caused by: java.sql.SQLException: Field 'dtype' doesn't have a default
> value
> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:107 2)
> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3563)
> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3495)
> at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
> at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
> at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:26 93)
> at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedSta
> tement.java:2102)
> at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedState
> ment.java:2395)
> at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedState
> ment.java:2313)
> at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedState
> ment.java:2298)
> at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.
> executeAndExtract(IdentityGenerator.java:94)
> at org.hibernate.id.insert.AbstractReturningDelegate.performIns
> ert(AbstractReturningDelegate.java:57)
> ... 19 more
>
>
> As for the same name in different subclasses: The SyntacticElement and
> the SemanticElement both inherit from the same class. Both elements have
> an attribute with the same name, but of different types. Is there some
> way of resolving this issue with the SINGLE_TABLE inheritance mapping?
>
> Regards,
>
> Wolf
--
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 + EcoreUtil.Copier: Wrong ID ..? [message #544405 is a reply to message #544376] |
Fri, 02 July 2010 14:55 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Wolf,
If it works now it must have had some effect :-). The subtypes are all stored in the table of the root class/type, can
you check that table?
gr. Martin
On 07/02/2010 03:44 PM, Wolf Fischer wrote:
> Hi Martin,
>
> Thanks again! It works now! Just one more question:
> I followed the examples and instructions from the link (at least I think
> I did ;)). I added the annotations from within the Ecore-Editor, so that
> the file looks like the following:
>
> <eClassifiers xsi:type="ecore:EClass" name="SyntacticElement"
> eSuperTypes="#//Element">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="belongsToSyntacticScope"
> upperBound="-1" eType="#//SyntacticScope"
> eOpposite="#//SyntacticScope/consistsOfElements"/>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="referencedBySymbol" upperBound="-1"
> eType="#//SyntacticSymbol"
> eOpposite="#//SyntacticSymbol/referencesElement">
> <eAnnotations source="teneo.jpa">
> <details key="appinfo" value="@JoinColumn(name="referencedBySynSymbol")"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
>
>
> However if I look at the DB there is no column / table, named
> "referencedBySynSymbol" (I refreshed my DB several times). How is Teneo
> handling the internal mapping?
>
> Regards,
>
> Wolf
--
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
|
|
|
Powered by
FUDForum. Page generated in 0.04303 seconds