Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0052859Openbravo ERPA. Platformpublic2023-06-27 12:512023-07-08 00:55
AugustoMauch 
AugustoMauch 
normalmajorhave not tried
closedfixed 
5
 
PR23Q4 
Core
No
0052859: It is not possible to have computed columns both in m_product and m_offer_product
If we try to have computed columns both in the m_product and m_offer_product tables, the datasource response for both of those tables will fail.

For m_product:
- java.lang.ClassCastException: class org.openbravo.model.pricing.priceadjustment.Product_ComputedColumns$HibernateProxy$GcoEEn1j cannot be cast to class org.openbravo.model.common.plm.Product_ComputedColumns (org.openbravo.model.pricing.priceadjustment.Product_ComputedColumns$HibernateProxy$GcoEEn1j and org.openbravo.model.common.plm.Product_ComputedColumns are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @51e7ffe5)

For m_offer_product:
- org.openbravo.base.util.CheckException: Property testOffer does not exist for entity Product_ComputedColumns

The cause is that when generating the entities for the computed columns, the names of the entities are built using <className>_ComputedColumns, and the name for both m_product and m_offer_product classes is Product, resulting in two entities with the same name (Product_ComputedColumn).
- Add computed columns (and fields) to both m_product and m_offer_product. You can use the same sql logic in both of them: select m_productprice.m_productprice_id from m_productprice where m_productprice.m_product_id=m_product_id limit 1, create a String column.
- Compile the application, restart tomcat
- Open the Product window. The following error will be thrown: java.lang.ClassCastException: class org.openbravo.model.pricing.priceadjustment.Product_ComputedColumns$HibernateProxy$GcoEEn1j cannot be cast to class org.openbravo.model.common.plm.Product_ComputedColumns
- Open Discounts and Promotions, select a record, select the Products tab. The following error will be thrown: org.openbravo.base.util.CheckException: Property testOffer does not exist for entity Product_ComputedColumns
When building the entities of the computed column, use the entity name of the original entity as prefix (guaranteed to be unique) instead of the class name (not guaranteed)
No tags attached.
has duplicate defect 0052606 closed Triage Platform Base Unable to create a computed column for m_offer_product table 
Issue History
2023-06-27 12:51AugustoMauchNew Issue
2023-06-27 12:51AugustoMauchAssigned To => AugustoMauch
2023-06-27 12:51AugustoMauchModules => Core
2023-06-27 12:51AugustoMauchTriggers an Emergency Pack => No
2023-06-27 12:51AugustoMauchStatusnew => scheduled
2023-06-27 12:55hgbotNote Added: 0151669
2023-06-27 15:08PracticsIssue Monitored: Practics
2023-06-27 18:14AugustoMauchRelationship addedhas duplicate 0052606
2023-06-28 10:05AugustoMauchDescription Updatedbug_revision_view_page.php?rev_id=26366#r26366
2023-07-08 00:53hgbotNote Added: 0152202
2023-07-08 00:54hgbotNote Added: 0152203
2023-07-08 00:54hgbotNote Added: 0152204
2023-07-08 00:55hgbotNote Added: 0152205
2023-07-08 00:55hgbotResolutionopen => fixed
2023-07-08 00:55hgbotStatusscheduled => closed
2023-07-08 00:55hgbotFixed in Version => PR23Q4
2023-07-08 00:55hgbotNote Added: 0152206

Notes
(0151669)
hgbot   
2023-06-27 12:55   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/921 [^]
(0152202)
hgbot   
2023-07-08 00:53   
Merge Request created: https://gitlab.com/openbravo/ci/backoffice-api/-/merge_requests/44 [^]
(0152203)
hgbot   
2023-07-08 00:54   
Merge request merged: https://gitlab.com/openbravo/ci/backoffice-api/-/merge_requests/44 [^]
(0152204)
hgbot   
2023-07-08 00:54   
Repository: https://gitlab.com/openbravo/ci/backoffice-api [^]
Changeset: 6c16c98809824d1fef653f92161c9db2255b4146
Author: Javier Armendáriz <javier.armendariz@openbravo.com>
Date: 08-07-2023 00:52:37
URL: https://gitlab.com/openbravo/ci/backoffice-api/-/commit/6c16c98809824d1fef653f92161c9db2255b4146 [^]

Related to ISSUE-52859 API Change: Changed name of computed columns constants

---
M java/reference/java.japi.gz
---
(0152205)
hgbot   
2023-07-08 00:55   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/921 [^]
(0152206)
hgbot   
2023-07-08 00:55   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: cc662cc2242a424fbfca16af9a9ece7292ae3968
Author: Augusto Mauch <augusto.mauch@openbravo.com>
Date: 07-07-2023 21:08:49
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/cc662cc2242a424fbfca16af9a9ece7292ae3968 [^]

Fixes ISSUE-52859: The name of computed columns entities are not guaranteed to be unique.

The problem is that when generating the entities for the computed columns, we names of the entities are built using <className>_ComputedColumns, and the name for both m_product and m_offer_product classes is Product, resulting in two entities with the same name (Product_ComputedColumn).

To fix it, the name of the entities generated for the computed columns, the original entity name (guaranteed to be unique) will be used as prefix instead of the class name (not guaranteed).

Note that this change is an API change due to the name of the computed column entities being updated.

---
M src/org/openbravo/base/gen/entityComputedColumns.ftl
M src/org/openbravo/base/model/Entity.java
M src/org/openbravo/dal/core/DalMappingGenerator.java
---