Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Texo] IllegalArgumentException with example Identifiable
[Texo] IllegalArgumentException with example Identifiable [message #641187] Wed, 24 November 2010 14:04 Go to next message
Daniel  is currently offline Daniel
Messages: 16
Registered: June 2010
Junior Member
Hello,

I downloaded and tried "Org.eclipse.emf.texo.identifiable.zip" with MySQL. Executing EntityManager.persist() I get the following IllegalArgumentExeption:

EL Info]: 2010-11-24 14:45:00.283--ServerSession(28007789)--EclipseLink, version: Eclipse Persistence Services - 2.1.1.v20100817-r8050
[EL Info]: 2010-11-24 14:45:00.565--ServerSession(28007789)--test login successful
Exception in thread "main" java.lang.IllegalArgumentException: Object: Identifiable  [db_Id: 0] [db_version: 1] is not a known entity type.
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:4199)
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.persist(EntityManagerImpl.java:403)
	at test.Test.insert(Test.java:44)
	at test.Test.main(Test.java:55)


Because I read that MySQL doesn't work with strategy="AUTO" I changed to IDENTITY. Have a look at my orm.xml:

<?xml version="1.0" encoding="ASCII"?>
<orm:entity-mappings xmlns:orm="http://www.eclipse.org/eclipselink/xsds/persistence/orm" version="2.1">
  <orm:access>FIELD</orm:access>
  <orm:mapped-superclass access="FIELD" class="org.eclipse.emf.texo.test.model.base.identifiable.Identifiable">
    <orm:attributes>
      <orm:id name="db_Id">
        <orm:generated-value strategy="IDENTITY"/>
      </orm:id>
      <orm:version access="FIELD" name="db_version">
        <orm:convert></orm:convert>
      </orm:version>
    </orm:attributes>
  </orm:mapped-superclass>
  <orm:mapped-superclass access="PROPERTY" class="org.eclipse.emf.texo.test.model.base.identifiable.IdentifiableInterface">
    <orm:attributes>
      <orm:id access="PROPERTY" name="db_Id">
        <orm:generated-value strategy="IDENTITY"/>
        <orm:convert></orm:convert>
      </orm:id>
      <orm:version access="PROPERTY" name="db_version">
        <orm:convert></orm:convert>
      </orm:version>
    </orm:attributes>
  </orm:mapped-superclass>
</orm:entity-mappings>


Has somebody an idea what I have to do to create the table?

In the end my persistence.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
	version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
	<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
	    
	    <mapping-file>META-INF/orm.xml</mapping-file>
	
		<properties>
			<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
			<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/XXX" />
			<property name="javax.persistence.jdbc.user" value="XXX" />
			<property name="javax.persistence.jdbc.password" value="XXX" />

			<!-- EclipseLink should create the database schema automatically -->
			<property name="eclipselink.ddl-generation" value="create-tables" />
			<property name="eclipselink.ddl-generation.output-mode" value="database" />
		</properties>
	</persistence-unit>
</persistence>


Thanks in advance
Daniel

[Updated on: Wed, 24 November 2010 14:05]

Report message to a moderator

Re: IllegalArgumentException with example Identifiable [message #641199 is a reply to message #641187] Wed, 24 November 2010 14:30 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5339
Registered: July 2009
Senior Member
Hi Daniel,
Are you creating/persisting an Identifiable or a subtype of Identifiable? The Identifiable is mapped as a mapped
superclass which means that it does not have its own table, the efeatures of identifiable are placed in a table of the
subclass.
If you are directly persisting an identifiable, can you then try with a subclass?

gr. Martin

On 11/24/2010 03:04 PM, Daniel wrote:
> Hello,
>
> I downloaded and tried "Org.eclipse.emf.texo.identifiable.zip" with
> MySQL. Executing EntityManager.persist() I get the following
> IllegalArgumentExeption:
>
>
> EL Info]: 2010-11-24 14:45:00.283--ServerSession(28007789)--EclipseLink,
> version: Eclipse Persistence Services - 2.1.1.v20100817-r8050
> [EL Info]: 2010-11-24 14:45:00.565--ServerSession(28007789)--test login
> successful
> Exception in thread "main" java.lang.IllegalArgumentException: Object:
> Identifiable [db_Id: 0] [db_version: 1] is not a known entity type.
> at
> org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.reg isterNewObjectForPersist(UnitOfWorkImpl.java:4199)
>
> at
> org.eclipse.persistence.internal.jpa.EntityManagerImpl.persi st(EntityManagerImpl.java:403)
>
> at test.Test.insert(Test.java:44)
> at test.Test.main(Test.java:55)
>
>
> Because I read that MySQL doesn't work with strategy="AUTO" I changed to
> IDENTITY. Have a look at my orm.xml:
>
>
> <?xml version="1.0" encoding="ASCII"?>
> <orm:entity-mappings
> xmlns:orm="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
> version="2.1">
> <orm:access>FIELD</orm:access>
> <orm:mapped-superclass access="FIELD"
> class=" org.eclipse.emf.texo.test.model.base.identifiable.Identifiab le ">
> <orm:attributes>
> <orm:id name="db_Id">
> <orm:generated-value strategy="IDENTITY"/>
> </orm:id>
> <orm:version access="FIELD" name="db_version">
> <orm:convert></orm:convert>
> </orm:version>
> </orm:attributes>
> </orm:mapped-superclass>
> <orm:mapped-superclass access="PROPERTY"
> class=" org.eclipse.emf.texo.test.model.base.identifiable.Identifiab leInterface ">
>
> <orm:attributes>
> <orm:id access="PROPERTY" name="db_Id">
> <orm:generated-value strategy="IDENTITY"/>
> <orm:convert></orm:convert>
> </orm:id>
> <orm:version access="PROPERTY" name="db_version">
> <orm:convert></orm:convert>
> </orm:version>
> </orm:attributes>
> </orm:mapped-superclass>
> </orm:entity-mappings>
>
> Has somebody an idea what I have to do to create the table?
>
> In the end my persistence.xml:
>
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
> version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
> <persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
> <mapping-file>META-INF/orm.xml</mapping-file>
>
> <properties>
> <property name="javax.persistence.jdbc.driver"
> value="com.mysql.jdbc.Driver" />
> <property name="javax.persistence.jdbc.url"
> value="jdbc:mysql://localhost:3306/XXX" />
> <property name="javax.persistence.jdbc.user" value="XXX" />
> <property name="javax.persistence.jdbc.password" value="XXX" />
>
> <!-- EclipseLink should create the database schema automatically -->
> <property name="eclipselink.ddl-generation" value="create-tables" />
> <property name="eclipselink.ddl-generation.output-mode" value="database" />
> </properties>
> </persistence-unit>
> </persistence>
>
>
> Thanks in advance
> Daniel


--

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: IllegalArgumentException with example Identifiable [message #641263 is a reply to message #641199] Wed, 24 November 2010 16:36 Go to previous messageGo to next message
Daniel  is currently offline Daniel
Messages: 16
Registered: June 2010
Junior Member
Hello,

thank you for the advice. Now I have got created a table Smile

I created a new EClass (Person) within the .ecore and set property "ESuper Types" = Identifiable. After "Generate ORM Annotated Model" I got the annotated EClass Person with an ORM Annotation that contains an entity called Person. After executing persist() a table Person was created.

I also searched for the property rootExtendsClass as mentioned at Texo/ORM JPA Annotations Details but without success.

Best regards
Daniel

Re: IllegalArgumentException with example Identifiable [message #641269 is a reply to message #641263] Wed, 24 November 2010 17:14 Go to previous message
Martin Taal is currently offline Martin Taal
Messages: 5339
Registered: July 2009
Senior Member
Hi Daniel,
Yes that property can be found in the code generation annotations model:
http://wiki.eclipse.org/Texo/Code_Generation_Details

So there are 2 ways to get a super class in your generated java code:
1) the ecore-way, so define a super eclass in your ecore
2) the java way, let the generated java classes inherit from another java class (which is not generated)

I will update the wiki to show this.

btw, it is best to only have as little as possible in your annotations model (orm or code generation), so only annotate
what you want to change from the default.

gr. Martin

On 11/24/2010 05:36 PM, Daniel wrote:
> Hello,
>
> thank you for the advice. Now I have got created a table :)
> I created a new EClass (Person) within the .ecore and set property
> "ESuper Types" = Identifiable. After "Generate ORM Annotated Model" I
> got the annotated EClass Person with an ORM Annotation that contains an
> entity called Person. After executing persist() a table Person was created.
>
> I also searched for the property rootExtendsClass as mentioned at
> http://wiki.eclipse.org/Texo/ORM_JPA_Annotations_Details but without
> success.
>
> Best regards
> Daniel
>
>


--

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:"Save as" with multiple file formats
Next Topic:How to create a dynamic instances of two dependant Metamodels
Goto Forum:
  


Current Time: Fri Oct 24 14:42:11 GMT 2014

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

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