Home » Eclipse Projects » EclipseLink » [Teneo/Eclipselink] Incorrect Id mappings for subclasses
[Teneo/Eclipselink] Incorrect Id mappings for subclasses [message #557179] |
Sun, 05 September 2010 18:52 |
|
Please pardon the cross link as I recently posted this on the EMF forum, but after pondering the matter I wonder it the issue may be more a matter of how EclipseLink is behaving with the generate orm.xml - cheers Joel
Hi,
I am having a problem persisting a rather simple EMF model using Teneo with Eclipselink. The ORM that is generated appears correct to me and the database is created without an issue. But when I try to persist entities the generated SQL is trying to discriminate on a non existent primary key.
Is this a bug or have I defined my EMF incorrectly?
I am running Eclipse 3.6, EclipseLink 2.1.0, EMF Teneo EclipseLink 1.1.0 and EMF 2.6
Many thanks,
Joel
Here is the exception using H2
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.h2.jdbc.JdbcSQLException: Column ID not found; SQL statement:
UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = 1 WHERE (ID = 2) [42122-117]
Error Code: 42122
Call: UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = 1 WHERE (ID = 2)
Query: DataModifyQuery(sql="UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = ? WHERE (ID = ?)")
Here is the exception using Derby
[EL Fine]: Connection(1189166715)--UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = 1 WHERE (ID = 2)
[EL Fine]: VALUES(1)
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Column 'ID' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement then 'ID' is not a column in the target table.
Error Code: 20000
Call: UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = 1 WHERE (ID = 2)
Query: DataModifyQuery(sql="UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = ? WHERE (ID = ?)")
I will add the whole of the run's output at the end of this post for context.
The ecore model:
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="recipes"
nsURI="http:///com.mirthfullife.epicerie/epicerie.ecore" nsPrefix="com.mirthfullife.epicerie">
<eClassifiers xsi:type="ecore:EClass" name="RecipeCatalogue" eSuperTypes="#//Identifiable">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="This is the receptacle of all recipes. Any system may have one or more RecipeCatalogue objects.

RecipeCatalogue knows about and can report on all the Recipe objects it contains."/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EReference" name="myRecipes" upperBound="-1"
eType="#//Recipe" containment="true" eOpposite="#//Recipe/myCatalogue"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
defaultValueLiteral="Epicerie Recipe Catalogue">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="The name of the catalogue."/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="BookKeeper" abstract="true" eSuperTypes="#//Identifiable">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="The BookKeeper class knows about all book keeping type information that it is useful to record for any given Recipe, such as its creation date and its date of last modification.

This information is automatically generated and maintained by the system and reported to the user, if needed, as read only information."/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="creationDate" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="The creation date of this object. This is automatically set at object creation time and cannot be modified."/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="modificationDate" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="The date of last modification of the object. This is automatically set each time the object is edited."/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Recipe" abstract="true" eSuperTypes="#//BookKeeper">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="The base (abstract) class of all recipes that are held in the system. 
Any concrete type of recipe (such as PaperRecipe, WebRecipe etc.) extends this base type.

This class holds all cataloguing information that is needed to retrieve recipes from the system. Its essential attributes are its unique ID, which is created by the system at recipe creation time, and its name, which identify the recipe to the user.

As a BookeKeeper object, Recipe also knows about all bookkeeping attributes, such as creation and modification date, which are automatically maintained by the system.

Recipe objects are contained in one and only one specific RecipeCatalogue, of which they are aware."/>
</eAnnotations>
<eOperations name="getSource" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="This method returns the source of this Recipe, which describes whether this is an internal recipe, a recipe held on loose paper, a book recipe etc.

This is an abstract method, implemented by each concerete Recipe subclass. "/>
</eAnnotations>
</eOperations>
<eStructuralFeatures xsi:type="ecore:EReference" name="myCatalogue" lowerBound="1"
eType="#//RecipeCatalogue" eOpposite="#//RecipeCatalogue/myRecipes"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="The name of the recipe. It does not have to be unique, as we allow multiple recipes with the same name."/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="course" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="The course represented by this recipe, namely aperitif, petiser, main course, dessert. 

This field will eventually be an enum provided by the persistent store and selected by the user, but it is at first modellled as a simple String for simplicity, with the user being able to enter free text in it."/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="meal" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="The meal this recipe belongs to, namely breakfast, brunch, lunch, snack, dinner. 

This field will eventually be an enum provided by the persistent store and selected by the user, but it is at first modellled as a simple String for simplicity, with the user being able to enter free text in it."/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="primaryIngredient" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="The ingredient that primarily characterises this recipe, such as meat, fowl, fish, vegetable etc.

This field will eventually be an enum provided by the persistent store and selected by the user, but it is at first modellled as a simple String for simplicity, with the user being able to enter free text in it."/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="PaperRecipe" eSuperTypes="#//Recipe">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="This is a concrete Recipe that represents a recipe that is currently stored on loose leaf paper in VO's catalogue. 

Such a class does not need more information than is already provided by its superclass, as all other details, such as ingredients, preparation, images etc. are contained in its paper representation. As such, objects of this type essentially represent references to the external paper recipes.

PaperRecipe is especially useful during the initial adoption of L'Epicerie, when the user may want to start cataloguing her recipes in order to get some of the benefits of L'Epicerie but without spending too much time entering recipe details. A PaperRecipe may then be converted into a full blown recipe at any later time."/>
</eAnnotations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="WebRecipe" eSuperTypes="#//Recipe">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="This is a concrete Recipe that represents a recipe that is currently stored on an external website. 

Such a class does not need more information than is already provided by its superclass, as all other details, such as ingredients, preparation, images etc. are contained in its web representation. As such, objects of this type essentially represent references to the external web recipes.

WebRecipe is especially useful during the initial adoption of L'Epicerie, when the user may want to start cataloguing her recipes in order to get some of the benefits of L'Epicerie but without spending too much time entering recipe details. 
A WebRecipe may then be converted into a full blown recipe at any later time."/>
</eAnnotations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="BookRecipe" eSuperTypes="#//Recipe">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="This is a concrete Recipe that represents a recipe that is currently stored in a cookery book. 

Such a class does not need more information than is already provided by its superclass, as all other details, such as ingredients, preparation, images etc. are contained in its book representation. As such, objects of this type essentially represent references to the external book recipes.

BookRecipe is especially useful during the initial adoption of L'Epicerie, when the user may want to start cataloguing her recipes in order to get some of the benefits of L'Epicerie but without spending too much time entering recipe details.
A BookRecipe may then be converted into a full blown recipe at any later time."/>
</eAnnotations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Identifiable" abstract="true">
<eAnnotations source="teneo.jpa">
<details key="value" value="@MappedSuperclass"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ELong">
<eAnnotations source="teneo.jpa">
<details key="value" value="@Id
@GeneratedValue"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="version" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ELong">
<eAnnotations source="teneo.jpa">
<details key="value" value="@Version"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
</ecore:EPackage>
The orm.xml
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
version="1.0">
<persistence-unit-metadata>
<xml-mapping-metadata-complete />
<persistence-unit-defaults>
<access>FIELD</access>
</persistence-unit-defaults>
</persistence-unit-metadata>
<mapped-superclass
class="com.mirthfullife.epicerie.recipes.impl.IdentifiableImpl">
<attributes>
<id name="id">
<generated-value strategy="AUTO" />
</id>
<basic name="eContainerFeatureID">
<column name="ECONT_FEAT_ID" />
</basic>
<version name="version" />
</attributes>
</mapped-superclass>
<entity class="com.mirthfullife.epicerie.recipes.impl.RecipeCatalogueImpl"
name="RecipeCatalogue">
<table name="RECIPECATALOGUE" />
<inheritance strategy="JOINED" />
<attributes>
<basic fetch="EAGER" name="name" optional="false" />
<one-to-many fetch="LAZY" name="myRecipes"
target-entity="com.mirthfullife.epicerie.recipes.impl.RecipeImpl">
<join-column insertable="true" name="RECIPE_MYCATALOGUE_ID"
nullable="true" unique="false" updatable="true" />
<cascade>
<cascade-all />
</cascade>
</one-to-many>
</attributes>
</entity>
<entity class="com.mirthfullife.epicerie.recipes.impl.BookKeeperImpl"
name="BookKeeper">
<table name="BOOKKEEPER" />
<inheritance strategy="JOINED" />
<attributes>
<basic fetch="EAGER" name="creationDate" optional="false">
<temporal>TIMESTAMP</temporal>
</basic>
<basic fetch="EAGER" name="modificationDate" optional="false">
<temporal>TIMESTAMP</temporal>
</basic>
</attributes>
</entity>
<entity class="com.mirthfullife.epicerie.recipes.impl.RecipeImpl"
name="Recipe">
<table name="RECIPE" />
<primary-key-join-column name="BOOKKEEPER_ID" />
<attributes>
<basic fetch="EAGER" name="name" optional="false" />
<basic fetch="EAGER" name="course" optional="true" />
<basic fetch="EAGER" name="meal" optional="true" />
<basic fetch="EAGER" name="primaryIngredient" optional="true" />
<many-to-one name="eContainer"
target-entity="com.mirthfullife.epicerie.recipes.impl.RecipeCatalogueImpl">
<join-column name="RECIPE_MYCATALOGUE_ID" />
<cascade>
<cascade-all />
</cascade>
</many-to-one>
</attributes>
</entity>
<entity class="com.mirthfullife.epicerie.recipes.impl.PaperRecipeImpl"
name="PaperRecipe">
<table name="PAPERRECIPE" />
<primary-key-join-column name="RECIPE_ID" />
<attributes />
</entity>
<entity class="com.mirthfullife.epicerie.recipes.impl.WebRecipeImpl"
name="WebRecipe">
<table name="WEBRECIPE" />
<primary-key-join-column name="RECIPE_ID" />
<attributes />
</entity>
<entity class="com.mirthfullife.epicerie.recipes.impl.BookRecipeImpl"
name="BookRecipe">
<table name="BOOKRECIPE" />
<primary-key-join-column name="RECIPE_ID" />
<attributes />
</entity>
</entity-mappings>
The whole run
[EL Config]: The access type for the persistent class [class com.mirthfullife.epicerie.recipes.impl.IdentifiableImpl] is set to [FIELD].
[EL Config]: The access type for the persistent class [class com.mirthfullife.epicerie.recipes.impl.BookKeeperImpl] is set to [FIELD].
[EL Config]: The access type for the persistent class [class com.mirthfullife.epicerie.recipes.impl.RecipeImpl] is set to [FIELD].
[EL Config]: The access type for the persistent class [class com.mirthfullife.epicerie.recipes.impl.RecipeCatalogueImpl] is set to [FIELD].
[EL Config]: The access type for the persistent class [class com.mirthfullife.epicerie.recipes.impl.PaperRecipeImpl] is set to [FIELD].
[EL Config]: The access type for the persistent class [class com.mirthfullife.epicerie.recipes.impl.WebRecipeImpl] is set to [FIELD].
[EL Config]: The access type for the persistent class [class com.mirthfullife.epicerie.recipes.impl.BookRecipeImpl] is set to [FIELD].
[EL Config]: The column name for element [field id] is being defaulted to: ID.
[EL Config]: The column name for element [field version] is being defaulted to: VERSION.
[EL Config]: The discriminator column name for the root inheritance class [class com.mirthfullife.epicerie.recipes.impl.BookKeeperImpl] is being defaulted to: DTYPE.
[EL Config]: The column name for element [field id] is being defaulted to: ID.
[EL Config]: The column name for element [field creationDate] is being defaulted to: CREATIONDATE.
[EL Config]: The column name for element [field modificationDate] is being defaulted to: MODIFICATIONDATE.
[EL Config]: The column name for element [field version] is being defaulted to: VERSION.
[EL Config]: The primary key column name for the inheritance class [class com.mirthfullife.epicerie.recipes.impl.RecipeImpl] is being defaulted to: ID.
[EL Config]: The column name for element [field primaryIngredient] is being defaulted to: PRIMARYINGREDIENT.
[EL Config]: The column name for element [field course] is being defaulted to: COURSE.
[EL Config]: The column name for element [field name] is being defaulted to: NAME.
[EL Config]: The column name for element [field meal] is being defaulted to: MEAL.
[EL Config]: The discriminator column name for the root inheritance class [class com.mirthfullife.epicerie.recipes.impl.RecipeCatalogueImpl] is being defaulted to: DTYPE.
[EL Config]: The column name for element [field id] is being defaulted to: ID.
[EL Config]: The column name for element [field name] is being defaulted to: NAME.
[EL Config]: The column name for element [field version] is being defaulted to: VERSION.
[EL Config]: The primary key column name for the inheritance class [class com.mirthfullife.epicerie.recipes.impl.PaperRecipeImpl] is being defaulted to: ID.
[EL Config]: The primary key column name for the inheritance class [class com.mirthfullife.epicerie.recipes.impl.WebRecipeImpl] is being defaulted to: ID.
[EL Config]: The primary key column name for the inheritance class [class com.mirthfullife.epicerie.recipes.impl.BookRecipeImpl] is being defaulted to: ID.
[EL Config]: The primary key column name for the mapping element [field eContainer] is being defaulted to: ID.
[EL Warning]: Element [field myRecipes] within entity class [class com.mirthfullife.epicerie.recipes.impl.RecipeCatalogueImpl] uses a collection type [class org.eclipse.emf.common.util.EList] when the JPA specification only supports java.util.Collection, java.util.Set, java.util.List, or java.util.Map. This type is supported with eager loading; using lazy loading with this collection type requires additional configuration and an IndirectContainer implementation that extends [class org.eclipse.emf.common.util.EList] or setting the mapping to use basic indirection and the type to be ValueholderInterface.
[EL Config]: The primary key column name for the mapping element [field myRecipes] is being defaulted to: ID.
[EL Info]: property eclipselink.jdbc.driver is deprecated, property javax.persistence.jdbc.driver should be used instead.
[EL Info]: property eclipselink.jdbc.url is deprecated, property javax.persistence.jdbc.url should be used instead.
[EL Info]: EclipseLink, version: Eclipse Persistence Services - 2.1.0.v20100614-r7608
[EL Config]: Connection(2134123845)--connecting(DatabaseLogin(
platform=>H2Platform
user name=> ""
datasource URL=> "jdbc:h2:H2/teneo"
))
[EL Config]: Connection(1604399928)--Connected: jdbc:h2:H2/teneo
User:
Database: H2 Version: 1.1.117 (2009-08-09)
Driver: H2 JDBC Driver Version: 1.1.117 (2009-08-09)
[EL Config]: Connection(1344918164)--connecting(DatabaseLogin(
platform=>H2Platform
user name=> ""
datasource URL=> "jdbc:h2:H2/teneo"
))
[EL Config]: Connection(1774197673)--Connected: jdbc:h2:H2/teneo
User:
Database: H2 Version: 1.1.117 (2009-08-09)
Driver: H2 JDBC Driver Version: 1.1.117 (2009-08-09)
[EL Info]: epicerie login successful
[EL Fine]: Connection(1604399928)--ALTER TABLE RECIPE DROP CONSTRAINT FK_RECIPE_BOOKKEEPER_ID
[EL Fine]: Connection(1604399928)--ALTER TABLE RECIPE DROP CONSTRAINT FK_RECIPE_RECIPE_MYCATALOGUE_ID
[EL Fine]: Connection(1604399928)--ALTER TABLE BOOKRECIPE DROP CONSTRAINT FK_BOOKRECIPE_RECIPE_ID
[EL Fine]: Connection(1604399928)--ALTER TABLE PAPERRECIPE DROP CONSTRAINT FK_PAPERRECIPE_RECIPE_ID
[EL Fine]: Connection(1604399928)--ALTER TABLE WEBRECIPE DROP CONSTRAINT FK_WEBRECIPE_RECIPE_ID
[EL Fine]: Connection(1604399928)--DROP TABLE RECIPE
[EL Fine]: Connection(1604399928)--CREATE TABLE RECIPE (BOOKKEEPER_ID BIGINT NOT NULL, PRIMARYINGREDIENT VARCHAR, COURSE VARCHAR, NAME VARCHAR, MEAL VARCHAR, RECIPE_MYCATALOGUE_ID BIGINT, PRIMARY KEY (BOOKKEEPER_ID))
[EL Fine]: Connection(1604399928)--DROP TABLE BOOKRECIPE
[EL Fine]: Connection(1604399928)--CREATE TABLE BOOKRECIPE (RECIPE_ID BIGINT NOT NULL, PRIMARY KEY (RECIPE_ID))
[EL Fine]: Connection(1604399928)--DROP TABLE PAPERRECIPE
[EL Fine]: Connection(1604399928)--CREATE TABLE PAPERRECIPE (RECIPE_ID BIGINT NOT NULL, PRIMARY KEY (RECIPE_ID))
[EL Fine]: Connection(1604399928)--DROP TABLE BOOKKEEPER
[EL Fine]: Connection(1604399928)--CREATE TABLE BOOKKEEPER (ID BIGINT NOT NULL, DTYPE VARCHAR(31), CREATIONDATE TIMESTAMP, ECONT_FEAT_ID INTEGER, MODIFICATIONDATE TIMESTAMP, VERSION BIGINT, PRIMARY KEY (ID))
[EL Fine]: Connection(1604399928)--DROP TABLE RECIPECATALOGUE
[EL Fine]: Connection(1604399928)--CREATE TABLE RECIPECATALOGUE (ID BIGINT NOT NULL, DTYPE VARCHAR(31), ECONT_FEAT_ID INTEGER, NAME VARCHAR, VERSION BIGINT, PRIMARY KEY (ID))
[EL Fine]: Connection(1604399928)--DROP TABLE WEBRECIPE
[EL Fine]: Connection(1604399928)--CREATE TABLE WEBRECIPE (RECIPE_ID BIGINT NOT NULL, PRIMARY KEY (RECIPE_ID))
[EL Fine]: Connection(1604399928)--ALTER TABLE RECIPE ADD CONSTRAINT FK_RECIPE_BOOKKEEPER_ID FOREIGN KEY (BOOKKEEPER_ID) REFERENCES BOOKKEEPER (ID)
[EL Fine]: Connection(1604399928)--ALTER TABLE RECIPE ADD CONSTRAINT FK_RECIPE_RECIPE_MYCATALOGUE_ID FOREIGN KEY (RECIPE_MYCATALOGUE_ID) REFERENCES RECIPECATALOGUE (ID)
[EL Fine]: Connection(1604399928)--ALTER TABLE BOOKRECIPE ADD CONSTRAINT FK_BOOKRECIPE_RECIPE_ID FOREIGN KEY (RECIPE_ID) REFERENCES BOOKKEEPER (ID)
[EL Fine]: Connection(1604399928)--ALTER TABLE PAPERRECIPE ADD CONSTRAINT FK_PAPERRECIPE_RECIPE_ID FOREIGN KEY (RECIPE_ID) REFERENCES BOOKKEEPER (ID)
[EL Fine]: Connection(1604399928)--ALTER TABLE WEBRECIPE ADD CONSTRAINT FK_WEBRECIPE_RECIPE_ID FOREIGN KEY (RECIPE_ID) REFERENCES BOOKKEEPER (ID)
[EL Fine]: Connection(1604399928)--CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT NUMERIC(38), PRIMARY KEY (SEQ_NAME))
[EL Fine]: SELECT 1
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.h2.jdbc.JdbcSQLException: Table SEQUENCE already exists; SQL statement:
CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT NUMERIC(38), PRIMARY KEY (SEQ_NAME)) [42101-117]
Error Code: 42101
Call: CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT NUMERIC(38), PRIMARY KEY (SEQ_NAME))
Query: DataModifyQuery(sql="CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT NUMERIC(38), PRIMARY KEY (SEQ_NAME))")
[EL Fine]: Connection(1604399928)--DELETE FROM SEQUENCE WHERE SEQ_NAME = SEQ_GEN
[EL Fine]: Connection(1604399928)--SELECT * FROM SEQUENCE WHERE SEQ_NAME = SEQ_GEN
[EL Fine]: Connection(1604399928)--INSERT IGNORE INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values (SEQ_GEN, 0)
[EL Fine]: Connection(1604399928)--SELECT ID, DTYPE, ECONT_FEAT_ID, NAME, VERSION FROM RECIPECATALOGUE WHERE ((NAME = epicerie_recipe_catalogue) AND (DTYPE = RecipeCatalogueImpl))
[EL Fine]: Connection(1774197673)--UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + 50 WHERE SEQ_NAME = SEQ_GEN
[EL Fine]: Connection(1774197673)--SELECT SEQ_COUNT FROM SEQUENCE WHERE SEQ_NAME = SEQ_GEN
[EL Fine]: Connection(1774197673)--INSERT IGNORE INTO RECIPECATALOGUE (ID, ECONT_FEAT_ID, NAME, VERSION, DTYPE) VALUES (1, 0, epicerie_recipe_catalogue, 1, RecipeCatalogueImpl)
[EL Fine]: Connection(1774197673)--INSERT IGNORE INTO BOOKKEEPER (ID, CREATIONDATE, ECONT_FEAT_ID, MODIFICATIONDATE, VERSION, DTYPE) VALUES (3, NULL, 4, NULL, 1, BookRecipeImpl)
[EL Fine]: Connection(1774197673)--INSERT IGNORE INTO RECIPE (PRIMARYINGREDIENT, COURSE, NAME, MEAL, RECIPE_MYCATALOGUE_ID, BOOKKEEPER_ID) VALUES (NULL, NULL, NULL, NULL, 1, 3)
[EL Fine]: Connection(1774197673)--INSERT IGNORE INTO BOOKRECIPE (RECIPE_ID) VALUES (3)
[EL Fine]: Connection(1774197673)--INSERT IGNORE INTO BOOKKEEPER (ID, CREATIONDATE, ECONT_FEAT_ID, MODIFICATIONDATE, VERSION, DTYPE) VALUES (4, NULL, 4, NULL, 1, PaperRecipeImpl)
[EL Fine]: Connection(1774197673)--INSERT IGNORE INTO RECIPE (PRIMARYINGREDIENT, COURSE, NAME, MEAL, RECIPE_MYCATALOGUE_ID, BOOKKEEPER_ID) VALUES (NULL, NULL, NULL, NULL, 1, 4)
[EL Fine]: Connection(1774197673)--INSERT IGNORE INTO PAPERRECIPE (RECIPE_ID) VALUES (4)
[EL Fine]: Connection(1774197673)--INSERT IGNORE INTO BOOKKEEPER (ID, CREATIONDATE, ECONT_FEAT_ID, MODIFICATIONDATE, VERSION, DTYPE) VALUES (2, NULL, 4, NULL, 1, WebRecipeImpl)
[EL Fine]: Connection(1774197673)--INSERT IGNORE INTO RECIPE (PRIMARYINGREDIENT, COURSE, NAME, MEAL, RECIPE_MYCATALOGUE_ID, BOOKKEEPER_ID) VALUES (NULL, NULL, NULL, NULL, 1, 2)
[EL Fine]: Connection(1774197673)--INSERT IGNORE INTO WEBRECIPE (RECIPE_ID) VALUES (2)
[EL Fine]: Connection(1774197673)--UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = 1 WHERE (ID = 2)
[EL Fine]: SELECT 1
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.h2.jdbc.JdbcSQLException: Column ID not found; SQL statement:
UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = 1 WHERE (ID = 2) [42122-117]
Error Code: 42122
Call: UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = 1 WHERE (ID = 2)
Query: DataModifyQuery(sql="UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = ? WHERE (ID = ?)")
|
|
| |
Re: [Teneo/Eclipselink] Incorrect Id mappings for subclasses [message #557325 is a reply to message #557309] |
Mon, 06 September 2010 17:42 |
|
I would be happy to attach source and diagram, but that is not a option on the forum as far as I know. Two paths I could follow is to email you direct or open a bug report. Which do you think is most appropriate in this case?
The subclasses do not redefine the ID; the reason for the Identifiable is create the ID once at the top of each hierarchy rather than redefining it everywhere. In EMF it is non trivial to create a persistent ID, so the strategy of doing it once saves effort and mistakes. I borrowed this pattern from the EclipseLink modified EMF Library example. It seems to work only at the first level of inheritance which is rather restricting. And yes the strategy is defined only once right at the top and peculates down.
Thanks,
Joel
Shaun Smith wrote on Mon, 06 September 2010 16:25 | I'm not adept at reading ecore models so can you post a diagram of the class hierarchy or attach the generated source? I see that you have a mappedsuperclass IdentifiableImpl that defines an ID and I'm wondering if you have subclasses that attempt to redefined identity? I'm also wondering if you're defining the inheritance strategy only once in each hierarchy.
--Shaun
|
|
|
| |
Re: [Teneo/Eclipselink] Incorrect Id mappings for subclasses [message #557473 is a reply to message #557454] |
Tue, 07 September 2010 14:46 |
|
I expected this was the case, so it appears that this is a Teneo issue as it is Teneo that generates the ORM. I will ask Martin if he can have another think about this. - Thanks
Chris Delahunt wrote on Tue, 07 September 2010 14:47 | Hello Joel,
What is the purpose of the <primary-key-join-column name="BOOKKEEPER_ID" /> tag within the RecipeImpl orm mapping? This seems to cause the problem, as EclipseLink seems unsure of what the ID field is - it creates the table using BOOKKEEPER_ID instead because of this tag. Removing the tag will correct this problem.
Best Regards,
Chris
|
|
|
|
Re: [Teneo/Eclipselink] Incorrect Id mappings for subclasses [message #557478 is a reply to message #557473] |
Tue, 07 September 2010 14:55 |
|
I dislike cross posting this way and wish that the forums supported sane multi list postings like in the good old days...
That said I have posted a query on the EMF forum to see if I can get someone from Teneo to comment.
Joel Rosi-Schwartz wrote on Tue, 07 September 2010 15:46 | I expected this was the case, so it appears that this is a Teneo issue as it is Teneo that generates the ORM. I will ask Martin if he can have another think about this. - Thanks
|
|
|
| |
Re: [Teneo/Eclipselink] Incorrect Id mappings for subclasses [message #557500 is a reply to message #557498] |
Tue, 07 September 2010 20:01 |
|
Hi Christian,
Here is the stacktrace. As far as I can tell there is not an indication of who actually creates the update statement. Possibly this is because it is being ran under Junit and part to the trace has been lost. Tomorrow I will set up a small example to simply run this code from the Activator to see if I can catch more.
Thanks,
Joel
org.eclipse.emf.common.util.WrappedException: javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.h2.jdbc.JdbcSQLException: Column ID not found; SQL statement:
UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = 1 WHERE (ID = 2) [42122-117]
Error Code: 42122
Call: UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = 1 WHERE (ID = 2)
Query: DataModifyQuery(sql="UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = ? WHERE (ID = ?)")
at org.eclipse.emf.teneo.eclipselink.resource.EclipseLinkResourceImpl.doSave(EclipseLinkResourceImpl.java:492)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1406)
at org.eclipse.emf.teneo.eclipselink.resource.EclipseLinkResourceImpl.save(EclipseLinkResourceImpl.java:396)
at com.mirthfullife.epicerie.resource.provider.eclipselink.test.TestModelFactory.createRecipeCatalogueModel(TestModelFactory.java:38)
at com.mirthfullife.epicerie.resource.provider.eclipselink.test.ProviderIntegrationTest.exampleOfCreatePersistentResource(ProviderIntegrationTest.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.h2.jdbc.JdbcSQLException: Column ID not found; SQL statement:
UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = 1 WHERE (ID = 2) [42122-117]
Error Code: 42122
Call: UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = 1 WHERE (ID = 2)
Query: DataModifyQuery(sql="UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = ? WHERE (ID = ?)")
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:102)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
at org.eclipse.emf.teneo.eclipselink.resource.EclipseLinkResourceImpl.doSave(EclipseLinkResourceImpl.java:489)
... 28 more
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.h2.jdbc.JdbcSQLException: Column ID not found; SQL statement:
UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = 1 WHERE (ID = 2) [42122-117]
Error Code: 42122
Call: UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = 1 WHERE (ID = 2)
Query: DataModifyQuery(sql="UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = ? WHERE (ID = ?)")
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:797)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:863)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:583)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:526)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeCall(AbstractSession.java:980)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:206)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:192)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelectCall(DatasourceCallQueryMechanism.java:235)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelect(DatasourceCallQueryMechanism.java:215)
at org.eclipse.persistence.internal.queries.StatementQueryMechanism.executeNoSelect(StatementQueryMechanism.java:115)
at org.eclipse.persistence.queries.DataModifyQuery.executeDatabaseQuery(DataModifyQuery.java:85)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:736)
at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:643)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2909)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1291)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1273)
at org.eclipse.persistence.mappings.OneToManyMapping.updateTargetRowPostInsertSource(OneToManyMapping.java:1274)
at org.eclipse.persistence.mappings.OneToManyMapping.performDataModificationEvent(OneToManyMapping.java:846)
at org.eclipse.persistence.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:157)
at org.eclipse.persistence.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:3348)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1422)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:546)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1527)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:200)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1148)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)
... 30 more
Caused by: org.h2.jdbc.JdbcSQLException: Column ID not found; SQL statement:
UPDATE RECIPE SET RECIPE_MYCATALOGUE_ID = 1 WHERE (ID = 2) [42122-117]
at org.h2.message.Message.getSQLException(Message.java:105)
at org.h2.message.Message.getSQLException(Message.java:116)
at org.h2.message.Message.getSQLException(Message.java:75)
at org.h2.expression.ExpressionColumn.optimize(ExpressionColumn.java:128)
at org.h2.expression.Comparison.optimize(Comparison.java:133)
at org.h2.command.dml.Update.prepare(Update.java:171)
at org.h2.command.Parser.prepareCommand(Parser.java:235)
at org.h2.engine.Session.prepareLocal(Session.java:415)
at org.h2.engine.Session.prepareCommand(Session.java:376)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1049)
at org.h2.jdbc.JdbcStatement.executeUpdate(JdbcStatement.java:112)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:786)
... 55 more
|
|
| |
Re: [Teneo/Eclipselink] Incorrect Id mappings for subclasses [message #557814 is a reply to message #557682] |
Thu, 09 September 2010 05:29 |
|
Hi Chris,
My model and project is simple enough at the moment, but but they utilise Spring to initialise all bundles. I will have to strip this back to a basic test case to reduce complications. I will not be able to do this till Saturday.
Many Thanks,
Joel
Chris Delahunt wrote on Wed, 08 September 2010 14:59 | Hello Joel,
I looked a bit further with the stack trace, see that the update statement is issued to set the foreign key, even though it is set correctly in the insert statement. Looking again at the mappings, this is occuring because the RecipeImpl has a Many-to-one to RecipeCatalogueImpl which is setting the value in the insert statement, but the RecipeCatalogueImpl has an independent One-to-many back to RecipeImpl that is using a join-column, which is causing the update statement.
This is a problem because it means there are two potentially independent mappings trying to set the RECIPE's RECIPE_MYCATALOGUE_ID field. A bug should be filed in EclipseLink to throw an error that there are multiple writable mappings for this field, and the the orm needs to be changed so that the One-to-Many is 'mapped-by' the eContainer attribute.
There could also be another bug in EclipseLink since the update statement should still not be using the "ID" field. I'll try to file a bug if I can reproduce it without the extra writable mappings.
Best Regards,
Chris
|
|
|
|
Goto Forum:
Current Time: Wed Sep 25 16:12:06 GMT 2024
Powered by FUDForum. Page generated in 0.06729 seconds
|