cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vadim Vertinskiy (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CAY-2036) Incorrect mapping of database tables from different model maps
Date Wed, 04 Nov 2015 12:27:27 GMT

     [ https://issues.apache.org/jira/browse/CAY-2036?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Vadim Vertinskiy updated CAY-2036:
----------------------------------
    Description: 
1. Two models (model1.map.xml and model2.map.xml) with different defaultPackage and defaultCatalog
are included to cayenne project and both models contains declaration to two different tables
with the identical name:
--- model1.map.xml ---
....
	<property name="defaultPackage" value="com.models.model1"/>
	<property name="defaultCatalog" value="mydb1"/>
....
	<db-entity name="myobject" catalog="mydb1">
		<db-attribute name="DB1_ATTRIBUTE1" type="CHAR" length="5"/>
		<db-attribute name="DB1_ATTRIBUTE2" type="CHAR" length="5"/>
		<db-attribute name="DB1_ATTRIBUTE3" type="CHAR" length="5"/>
	</db-entity>
...
	<obj-entity name="MyObject" className="com.models.model1.MyObject" dbEntityName="myobject"
>
		<obj-attribute name="db1Attribute1" type="java.lang.String" db-attribute-path="DB1_ATTRIBUTE1"/>
		<obj-attribute name="db1Attribute2" type="java.lang.String" db-attribute-path="DB1_ATTRIBUTE2"/>
		<obj-attribute name="db1Attribute3" type="java.lang.String" db-attribute-path="DB1_ATTRIBUTE3"/>
	</obj-entity>


---- model2.map.xml ---

....
	<property name="defaultPackage" value="com.models.model2"/>
	<property name="defaultCatalog" value="mydb2"/>
....
	<db-entity name="myobject" catalog="mydb2">
		<db-attribute name="DB2_ATTRIBUTE1" type="CHAR" length="5"/>
		<db-attribute name="DB2_ATTRIBUTE2" type="CHAR" length="5"/>
		<db-attribute name="DB2_ATTRIBUTE3" type="CHAR" length="5"/>
	</db-entity>
...
	<obj-entity name="MyObject" className="com.models.model2.MyObject" dbEntityName="myobject"
>
		<obj-attribute name="db2Attribute1" type="java.lang.String" db-attribute-path="DB2_ATTRIBUTE1"/>
		<obj-attribute name="db2Attribute2" type="java.lang.String" db-attribute-path="DB2_ATTRIBUTE2"/>
		<obj-attribute name="db2Attribute3" type="java.lang.String" db-attribute-path="DB2_ATTRIBUTE3"/>
	</obj-entity>

2. Following code is used for selection of data from mydb2.myobject:
ObjectSelect.query(com.models.model2.MyObject.class).where(com.models.model2.MyObject.DB2_ATTRIBUTE1.eq("A")).select(context);

3. Following sql is executed as result of query in p.2:
select DB1_ATTRIBUTE1, DB1_ATTRIBUTE2, DB1_ATTRIBUTE3 from mydb2.myobject where DB2_ATTRIBUTE1
= 'A';

As result, select block is formed incorrectly - set of db-attributes from mydb1.myobject table
(expected set of db-attributes from mydb2.myobject table)

  was:
1. Two models (model1.map.xml and model2.map.xml) with different defaultPackage and defaultCatalog
are included to cayenne project and both models contains declaration to two different tables
with the identical name:
--- model1.map.xml ---
....
	<property name="defaultPackage" value="com.models.model1"/>
	<property name="defaultCatalog" value="mydb1"/>
....
	<db-entity name="myobject" catalog="mydb1">
		<db-attribute name="DB1_ATTRIBUTE1" type="CHAR" length="5"/>
		<db-attribute name="DB1_ATTRIBUTE2" type="CHAR" length="5"/>
		<db-attribute name="DB1_ATTRIBUTE3" type="CHAR" length="5"/>
	</db-entity>
...
	<obj-entity name="MyObject" className="com.models.model1.MyObject" dbEntityName="myobject"
>
		<obj-attribute name="db1Attribute1" type="java.lang.String" db-attribute-path="DB1_ATTRIBUTE1"/>
		<obj-attribute name="db1Attribute2" type="java.lang.String" db-attribute-path="DB1_ATTRIBUTE2"/>
		<obj-attribute name="db1Attribute3" type="java.lang.String" db-attribute-path="DB1_ATTRIBUTE3"/>
	</obj-entity>


---- model2.map.xml ---

....
	<property name="defaultPackage" value="com.models.model2"/>
	<property name="defaultCatalog" value="mydb2"/>
....
	<db-entity name="myobject" catalog="mydb2">
		<db-attribute name="DB2_ATTRIBUTE1" type="CHAR" length="5"/>
		<db-attribute name="DB2_ATTRIBUTE2" type="CHAR" length="5"/>
		<db-attribute name="DB2_ATTRIBUTE3" type="CHAR" length="5"/>
	</db-entity>
...
	<obj-entity name="MyObject" className="com.models.model2.MyObject" dbEntityName="myobject"
>
		<obj-attribute name="db2Attribute1" type="java.lang.String" db-attribute-path="DB2_ATTRIBUTE1"/>
		<obj-attribute name="db2Attribute2" type="java.lang.String" db-attribute-path="DB2_ATTRIBUTE2"/>
		<obj-attribute name="db2Attribute3" type="java.lang.String" db-attribute-path="DB2_ATTRIBUTE3"/>
	</obj-entity>

2. Following code is used for selection of data from mydb2.myobject:
ObjectSelect.query(com.models.model2.MyObject.class).where(com.models.model2.MyObject.DB2_ATTRIBUTE1.eq("A")).select(context);

3. Following sql is executed as result of query in p.2:
select DB1_ATTRIBUTE1, DB1_ATTRIBUTE2, DB1_ATTRIBUTE3 from mydb2.myobject where DB2_ATTRIBUTE1
= 'A';

As result, select block is formed incorrectly - set of db-attributes form mydb1.myobject table
(expected set of db-attributes from mydb2.myobject table)


> Incorrect mapping of database tables from different model maps
> --------------------------------------------------------------
>
>                 Key: CAY-2036
>                 URL: https://issues.apache.org/jira/browse/CAY-2036
>             Project: Cayenne
>          Issue Type: Bug
>            Reporter: Vadim Vertinskiy
>
> 1. Two models (model1.map.xml and model2.map.xml) with different defaultPackage and defaultCatalog
are included to cayenne project and both models contains declaration to two different tables
with the identical name:
> --- model1.map.xml ---
> ....
> 	<property name="defaultPackage" value="com.models.model1"/>
> 	<property name="defaultCatalog" value="mydb1"/>
> ....
> 	<db-entity name="myobject" catalog="mydb1">
> 		<db-attribute name="DB1_ATTRIBUTE1" type="CHAR" length="5"/>
> 		<db-attribute name="DB1_ATTRIBUTE2" type="CHAR" length="5"/>
> 		<db-attribute name="DB1_ATTRIBUTE3" type="CHAR" length="5"/>
> 	</db-entity>
> ...
> 	<obj-entity name="MyObject" className="com.models.model1.MyObject" dbEntityName="myobject"
>
> 		<obj-attribute name="db1Attribute1" type="java.lang.String" db-attribute-path="DB1_ATTRIBUTE1"/>
> 		<obj-attribute name="db1Attribute2" type="java.lang.String" db-attribute-path="DB1_ATTRIBUTE2"/>
> 		<obj-attribute name="db1Attribute3" type="java.lang.String" db-attribute-path="DB1_ATTRIBUTE3"/>
> 	</obj-entity>
> ---- model2.map.xml ---
> ....
> 	<property name="defaultPackage" value="com.models.model2"/>
> 	<property name="defaultCatalog" value="mydb2"/>
> ....
> 	<db-entity name="myobject" catalog="mydb2">
> 		<db-attribute name="DB2_ATTRIBUTE1" type="CHAR" length="5"/>
> 		<db-attribute name="DB2_ATTRIBUTE2" type="CHAR" length="5"/>
> 		<db-attribute name="DB2_ATTRIBUTE3" type="CHAR" length="5"/>
> 	</db-entity>
> ...
> 	<obj-entity name="MyObject" className="com.models.model2.MyObject" dbEntityName="myobject"
>
> 		<obj-attribute name="db2Attribute1" type="java.lang.String" db-attribute-path="DB2_ATTRIBUTE1"/>
> 		<obj-attribute name="db2Attribute2" type="java.lang.String" db-attribute-path="DB2_ATTRIBUTE2"/>
> 		<obj-attribute name="db2Attribute3" type="java.lang.String" db-attribute-path="DB2_ATTRIBUTE3"/>
> 	</obj-entity>
> 2. Following code is used for selection of data from mydb2.myobject:
> ObjectSelect.query(com.models.model2.MyObject.class).where(com.models.model2.MyObject.DB2_ATTRIBUTE1.eq("A")).select(context);
> 3. Following sql is executed as result of query in p.2:
> select DB1_ATTRIBUTE1, DB1_ATTRIBUTE2, DB1_ATTRIBUTE3 from mydb2.myobject where DB2_ATTRIBUTE1
= 'A';
> As result, select block is formed incorrectly - set of db-attributes from mydb1.myobject
table (expected set of db-attributes from mydb2.myobject table)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message