[
https://issues.jboss.org/browse/TEIID-5599?page=com.atlassian.jira.plugin...
]
Christoph John commented on TEIID-5599:
---------------------------------------
Hello Steven,
attached you find the vdb xml description:
<?xml version="1.0" encoding="UTF-8"
standalone="no"?>
<vdb name="svc" version="1">
<description/>
<property name="validationDateTime" value="Fri Jan 11 01:38:15 CET
2019"/>
<property name="validationVersion" value="11.2.0"/>
<model name="my_nutri_diary">
<source connection-jndi-name="java:/my_nutri_diary"
name="my_nutri_diary" translator-name="mysql"/>
<metadata type="DDL">
<![CDATA[
CREATE FOREIGN TABLE Account (
idProfile long NOT NULL AUTO_INCREMENT OPTIONS(NAMEINSOURCE '`idProfile`',
NATIVE_TYPE 'BIGINT UNSIGNED'),
uuidUser string(36) NOT NULL OPTIONS(NAMEINSOURCE '`uuidUser`', NATIVE_TYPE
'CHAR'),
CONSTRAINT "PRIMARY" PRIMARY KEY(idProfile),
CONSTRAINT uuidUser_UNIQUE UNIQUE(uuidUser)
) OPTIONS(NAMEINSOURCE '`Account`', UPDATABLE 'TRUE');
CREATE FOREIGN TABLE Avatar (
fkProfile long NOT NULL OPTIONS(NAMEINSOURCE '`fkProfile`', NATIVE_TYPE
'BIGINT UNSIGNED'),
AvatarImg blob(65535) OPTIONS(NAMEINSOURCE '`AvatarImg`', NATIVE_TYPE
'BLOB'),
CONSTRAINT "PRIMARY" PRIMARY KEY(fkProfile),
CONSTRAINT fkAvatarToAccount FOREIGN KEY(fkProfile) REFERENCES Account(idProfile)
) OPTIONS(NAMEINSOURCE '`Avatar`', UPDATABLE 'TRUE');
CREATE FOREIGN TABLE BodyWeight (
idBodyWeight long NOT NULL AUTO_INCREMENT OPTIONS(NAMEINSOURCE '`idBodyWeight`',
NATIVE_TYPE 'BIGINT UNSIGNED'),
fkProfile long NOT NULL OPTIONS(NAMEINSOURCE '`fkProfile`', NATIVE_TYPE
'BIGINT UNSIGNED'),
WeightMeasurementDateTime timestamp NOT NULL OPTIONS(NAMEINSOURCE
'`WeightMeasurementDateTime`', NATIVE_TYPE 'DATETIME'),
Weight float NOT NULL OPTIONS(NAMEINSOURCE '`Weight`', NATIVE_TYPE 'FLOAT
UNSIGNED'),
CONSTRAINT "PRIMARY" PRIMARY KEY(idBodyWeight),
CONSTRAINT fkBodyWeightToAccount FOREIGN KEY(fkProfile) REFERENCES Account(idProfile)
) OPTIONS(NAMEINSOURCE '`BodyWeight`', UPDATABLE 'TRUE');
CREATE FOREIGN TABLE ConfigOptions (
fkProfile long NOT NULL OPTIONS(NAMEINSOURCE '`fkProfile`', NATIVE_TYPE
'BIGINT UNSIGNED'),
MUnitWeight string(2) DEFAULT 'kg' OPTIONS(NAMEINSOURCE '`MUnitWeight`',
NATIVE_TYPE 'ENUM'),
MUnitLength string(2) DEFAULT 'cm' OPTIONS(NAMEINSOURCE '`MUnitLength`',
NATIVE_TYPE 'ENUM'),
MUnitEnergy string(4) DEFAULT 'kcal' OPTIONS(NAMEINSOURCE
'`MUnitEnergy`', NATIVE_TYPE 'ENUM'),
MUnitLiquids string(2) DEFAULT 'ml' OPTIONS(NAMEINSOURCE
'`MUnitLiquids`', NATIVE_TYPE 'ENUM'),
MUnitTime string(3) DEFAULT '24h' OPTIONS(NAMEINSOURCE '`MUnitTime`',
NATIVE_TYPE 'ENUM'),
EnableDrinkReminder boolean DEFAULT '0' OPTIONS(NAMEINSOURCE
'`EnableDrinkReminder`', NATIVE_TYPE 'BIT'),
PreferredCountryCodeForSearch string(2) DEFAULT 'de' OPTIONS(NAMEINSOURCE
'`PreferredCountryCodeForSearch`', NATIVE_TYPE 'VARCHAR'),
EnableInternationalSearch boolean DEFAULT '1' OPTIONS(NAMEINSOURCE
'`EnableInternationalSearch`', NATIVE_TYPE 'BIT'),
NumberOfActiveMeals long DEFAULT '4' OPTIONS(NAMEINSOURCE
'`NumberOfActiveMeals`', NATIVE_TYPE 'INT UNSIGNED'),
Meal1Name string(45) OPTIONS(NAMEINSOURCE '`Meal1Name`', NATIVE_TYPE
'VARCHAR'),
Meal1StartTime time DEFAULT '00:00:00' OPTIONS(NAMEINSOURCE
'`Meal1StartTime`', NATIVE_TYPE 'TIME'),
Meal2Name string(45) OPTIONS(NAMEINSOURCE '`Meal2Name`', NATIVE_TYPE
'VARCHAR'),
Meal2StartTime time DEFAULT '00:00:00' OPTIONS(NAMEINSOURCE
'`Meal2StartTime`', NATIVE_TYPE 'TIME'),
Meal3Name string(45) OPTIONS(NAMEINSOURCE '`Meal3Name`', NATIVE_TYPE
'VARCHAR'),
Meal3StartTime time DEFAULT '00:00:00' OPTIONS(NAMEINSOURCE
'`Meal3StartTime`', NATIVE_TYPE 'TIME'),
Meal4Name string(45) OPTIONS(NAMEINSOURCE '`Meal4Name`', NATIVE_TYPE
'VARCHAR'),
Meal4StartTime time DEFAULT '00:00:00' OPTIONS(NAMEINSOURCE
'`Meal4StartTime`', NATIVE_TYPE 'TIME'),
Meal5Name string(45) OPTIONS(NAMEINSOURCE '`Meal5Name`', NATIVE_TYPE
'VARCHAR'),
Meal5StartTime time DEFAULT '00:00:00' OPTIONS(NAMEINSOURCE
'`Meal5StartTime`', NATIVE_TYPE 'TIME'),
Meal6Name string(45) OPTIONS(NAMEINSOURCE '`Meal6Name`', NATIVE_TYPE
'VARCHAR'),
Meal6StartTime time DEFAULT '00:00:00' OPTIONS(NAMEINSOURCE
'`Meal6StartTime`', NATIVE_TYPE 'TIME'),
CONSTRAINT "PRIMARY" PRIMARY KEY(fkProfile),
CONSTRAINT fkConfigOptionsToAccount FOREIGN KEY(fkProfile) REFERENCES Account(idProfile)
) OPTIONS(NAMEINSOURCE '`ConfigOptions`', UPDATABLE 'TRUE');
CREATE FOREIGN TABLE Profile (
fkProfile long NOT NULL OPTIONS(NAMEINSOURCE '`fkProfile`', NATIVE_TYPE
'BIGINT UNSIGNED'),
BodyHeight float DEFAULT '0.000' OPTIONS(NAMEINSOURCE '`BodyHeight`',
NATIVE_TYPE 'FLOAT UNSIGNED'),
GoalWeight float DEFAULT '0.000' OPTIONS(NAMEINSOURCE '`GoalWeight`',
NATIVE_TYPE 'FLOAT UNSIGNED'),
Gender string(1) DEFAULT 'm' OPTIONS(NAMEINSOURCE '`Gender`', NATIVE_TYPE
'ENUM'),
BirthDate date DEFAULT '1980-01-01' OPTIONS(NAMEINSOURCE '`BirthDate`',
NATIVE_TYPE 'DATE'),
ActivityLevel string(17) DEFAULT 'strActive' OPTIONS(NAMEINSOURCE
'`ActivityLevel`', NATIVE_TYPE 'ENUM'),
CONSTRAINT "PRIMARY" PRIMARY KEY(fkProfile),
CONSTRAINT fkProfileToAccount FOREIGN KEY(fkProfile) REFERENCES Account(idProfile)
) OPTIONS(NAMEINSOURCE '`Profile`', UPDATABLE 'TRUE');
]]>
</metadata>
</model>
<data-role allow-create-temporary-tables="false"
any-authenticated="true" grant-all="false" name="odata">
<description/>
<permission>
<resource-name>my_nutri_diary.ConfigOptions</resource-name>
<allow-delete>false</allow-delete>
<condition>ConfigOptions.fkProfile in (SELECT Account.idProfile FROM
Account WHERE Account.uuidUser = LEFT(user(), 36))</condition>
</permission>
<permission>
<resource-name>my_nutri_diary.Account</resource-name>
<allow-update>false</allow-update>
<allow-delete>false</allow-delete>
<condition>Account.uuidUser = LEFT(user(), 36)</condition>
</permission>
<permission>
<resource-name>my_nutri_diary.Profile</resource-name>
<allow-delete>false</allow-delete>
<condition>Profile.fkProfile in (SELECT Account.idProfile FROM Account
WHERE Account.uuidUser = LEFT(user(), 36))</condition>
</permission>
<permission>
<resource-name>my_nutri_diary</resource-name>
<allow-create>true</allow-create>
<allow-read>true</allow-read>
<allow-update>true</allow-update>
<allow-delete>true</allow-delete>
<allow-execute>false</allow-execute>
<allow-alter>false</allow-alter>
</permission>
<permission>
<resource-name>my_nutri_diary.BodyWeight</resource-name>
<condition>BodyWeight.fkProfile in (SELECT Account.idProfile FROM
Account WHERE Account.uuidUser = LEFT(user(), 36) )</condition>
</permission>
<permission>
<resource-name>sysadmin</resource-name>
<allow-create>false</allow-create>
<allow-read>false</allow-read>
<allow-update>false</allow-update>
<allow-delete>false</allow-delete>
<allow-execute>false</allow-execute>
<allow-alter>false</allow-alter>
</permission>
</data-role>
</vdb>
When creating an entity via POST message, it is expected, that the
returned message includes the primary key of the newly created instance. This is not the
case currently
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: TEIID-5599
URL:
https://issues.jboss.org/browse/TEIID-5599
Project: Teiid
Issue Type: Bug
Reporter: Christoph John
Assignee: Steven Hawkins
Priority: Critical
Fix For: 12.1
The following communication shows the issue. What I am doing here is to create a new
Account entity via post request. My underlaying mysql database requires the primary key in
the table to be set to NN (not null), hence, a value must be provided. Moreover the
primary key is set to autoincrement and is generated by the database. The only execepted
value here seems to be, to provide the key with value=0. The object is created in the
database as expected. However, Teiid answers with the created object, but again with the
primary key (idProfile) set as zero, instead to provide the newly created primary key.
POST Account HTTP/1.1
Accept:application/json;odata.metadata=minimal;IEEE754Compatible=true
Accept-Language:de-DE
Content-Type:application/json;charset=UTF-8;IEEE754Compatible=true
{"uuidUser":"65820574-7525-463b-9d20-5ee133a06b94","idProfile":"0"}
--batch_id-1547485733072-21
Content-Type:application/http
Content-Transfer-Encoding:binary
The response:
HTTP/1.1 201 Created
Location:
http://localhost/odata4/svc/my_nutri_diary/Account(0)
Content-Type: application/json;ieee754compatible=true;odata.metadata=minimal
Content-Length: 147
{"@odata.context":"http://localhost/odata4/svc/my_nutri_diary/$metadata#Account","idProfile":"0","uuidUser":"65820574-7525-463b-9d20-5ee133a06b94"}
--batch_e834eb7c-df0d-4e22-a423-78cd3638955f
Content-Type: application/http
Content-Transfer-Encoding: binary
--
This message was sent by Atlassian Jira
(v7.12.1#712002)