You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Vadim Vertinskiy (JIRA)" <ji...@apache.org> on 2015/11/04 13:25:27 UTC

[jira] [Commented] (CAY-2036) Incorrect mapping of database tables from different model maps

    [ https://issues.apache.org/jira/browse/CAY-2036?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14989466#comment-14989466 ] 

Vadim Vertinskiy commented on CAY-2036:
---------------------------------------

Notes:
This issue can be resolved with help of using different cayenne runtime for each model map.

> 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 form mydb1.myobject table (expected set of db-attributes from mydb2.myobject table)



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