You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "Jacques Le Roux (JIRA)" <ji...@apache.org> on 2014/05/19 12:26:38 UTC

[jira] [Comment Edited] (OFBIZ-5648) Extend primary keys

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

Jacques Le Roux edited comment on OFBIZ-5648 at 5/19/14 10:26 AM:
------------------------------------------------------------------

== TYPO ==
Let me better the context.

If you need to changes core (framework+applications) files and want to keep in sync with the ASF repo, you have to use patches to prevent merging issues, and worse surprises, when code is completly changed.

>From my experience, patches are always a pain to apply (EOL issues when using different development platforms) and maintain. So I try to maintain as less as possible patches. By extending entities in hot-deploy component, rather than changing core (framework+applications) entities I achieve that for data model changes. 

As you suggested I could rather redefine than extend entities in my hot-deploy component. But if for instance you want to increase the size of the orderId and invoiceId fields you have to redefine 77(!) entities. By extending them it's far easier to do (using C/P and regex-replace) and especially things are much more clear afterward. At a glance, you are able to know what have been changed, months, years later...

Also I decided this is a bug, because at the moment things are blurred. You have to get into the code (ModelEntity.addExtendEntity(), ~ line[365]) to know that extending a PK is not possible, even if it partially works. The field are resized in DB but you can't really use this new size. So, as I said already, it's inconsistent and confusing!

Note that contrary to what you said, it's not possible to add a primary key by extending an entity.  Anyway my change are not related and does not allow. It's only about overriding type, colName, description and enable-audit-log (other attributes are not supported and you have to get into code to know that (ModelEntity.addExtendEntity(), line[340]). 

I really see no serious reasons to not committing this change, which clarifies and makes things  consistent!


was (Author: jacques.le.roux):
Let me better the context.

If you need to changes core (framework+applications) files and want to keep in sync with the ASF repo, you have to use patches to prevent merging issues, and worse surprises, when code is completly changed.

>From my experience, patches are always a pain to apply (EOL issues when using different development platforms) and maintain. So I try to maintain as less as possible patches. By extending entities in hot-deploy component, rather than changing core (framework+applications) entities I achieve that for data model changes. 

As you suggested I could rather redefine than extend entities in my hot-deploy component. But if for instance you want to increase the size of the orderId and invoiceId fields you have to redefine 77(!) entities. By extending them it's far easier to do (using C/P and regex-replace) and especially things are much more clear afterward. At a glance, you are able to know what have been changed, months, years later...

Also I decided this is a bug, because at the moment things are blurred. You have to get into the code (ModelEntity.addExtendEntity(), ~ line[365]) to know that extending a PK is not possible, even if it partially works. The field are resized in DB but you can't really use this new size. So, as I said already, it's inconsistent and confusing!

Note that contrary to what you said, it's not possible to add a primary key by extending an entity.  Anyway my change are not related and does not allow. It's only about overriding type, colName, description and enable-audit-log (other attributes are not supported and you have to get into code to know that (ModelEntity.addExtendEntity(), line[340]). 

I really no serious reasons to not committing this change, which clarify and make things  consistent!

> Extend primary keys
> -------------------
>
>                 Key: OFBIZ-5648
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-5648
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>    Affects Versions: Release Branch 11.04, SVN trunk, Release Branch 12.04, Release Branch 13.07
>            Reporter: Jacques Le Roux
>            Assignee: Jacques Le Roux
>              Labels: entity, extend
>         Attachments: ModelEntity.java.patch, test.entity-extend.patch
>
>
> At http://svn.apache.org/viewvc?view=revision&revision=431009 David "Implemented extend-entity for entity definitions to support adding field, relation and index elements to an entity; this is now also used to support further separation of the framework from the applications"
> But primary keys were not taken into account
> {code}
> // this will always be true for now as extend-entity fielsd are always nonpks
> {code}
> It turned I needed to extend a PK and using the attached simple ModelEntity.java.patch, it definitely works quite well.
> I also attach a test.entity-extend.patch for testing with a localhost trunk demo instance
> # Apply the test.entity-extend.patch
> # Get to https://localhost:8443/webtools/control/FindGeneric?entityName=OrderHeader, you will see the orderId extension has been taken into account in the DB: orderId 	* 	String, VARCHAR(60). I also checked creating a Postgres DB, the column is 60 chars wide.
> # Get to https://localhost:8443/webtools/control/ViewGeneric?entityName=OrderHeader&enableEdit=true, you will see that you can't enter a PK longer than 20 chars
> # Apply the ModelEntity.java.patch, clean-data load-demo, restart
> # Get to https://localhost:8443/webtools/control/ViewGeneric?entityName=OrderHeader&enableEdit=true, you can enter a PK longer than 20 chars (up to 60) and create a new entity
> Though I already use this change in a custom project, I will wait some time before committing, thanks for your reviews



--
This message was sent by Atlassian JIRA
(v6.2#6252)