Hi,
Is there a way to extend the field type of a entity using extend-entity or any other similar mechanism without modifying the original entity definition. I tried using extend-entity by redefining the exiting field with a different data type, but it added a new column to the database table instead of altering it. Thanks, Raj |
Administrator
|
Raj,
If you look into ModelEntity.java you will find this comment // TODO: should we look for existing fields of the same name here? for now just add to list... Maybe someone will enchance it one day.... Jacques From: "Raj Saini" <[hidden email]> > Hi, > > Is there a way to extend the field type of a entity using extend-entity > or any other similar mechanism without modifying the original entity > definition. I tried using extend-entity by redefining the exiting field > with a different data type, but it added a new column to the database > table instead of altering it. > > Thanks, > > Raj > |
Jacques,
Thanks for the pointer. Should I create a Jira issue and may be I can pick it up when I understand the entity engine stuff clearly. Thanks, Raj Jacques Le Roux wrote: > Raj, > > If you look into ModelEntity.java you will find this comment > // TODO: should we look for existing fields of the same name here? for > now just add to list... > > Maybe someone will enchance it one day.... > > Jacques > > From: "Raj Saini" <[hidden email]> >> Hi, >> >> Is there a way to extend the field type of a entity using >> extend-entity or any other similar mechanism without modifying the >> original entity definition. I tried using extend-entity by redefining >> the exiting field with a different data type, but it added a new >> column to the database table instead of altering it. >> >> Thanks, >> >> Raj >> > |
Hi Raj
I don't think a solution for this would be straightforward, ofbiz wouldn't want to alter a column automatically because of the potential for data loss. Regards Scott 2008/5/18 Raj Saini <[hidden email]>: > Jacques, > > Thanks for the pointer. Should I create a Jira issue and may be I can pick > it up when I understand the entity engine stuff clearly. > > Thanks, > > Raj > > Jacques Le Roux wrote: > >> Raj, >> >> If you look into ModelEntity.java you will find this comment >> // TODO: should we look for existing fields of the same name here? for now >> just add to list... >> >> Maybe someone will enchance it one day.... >> >> Jacques >> >> From: "Raj Saini" <[hidden email]> >> >>> Hi, >>> >>> Is there a way to extend the field type of a entity using extend-entity >>> or any other similar mechanism without modifying the original entity >>> definition. I tried using extend-entity by redefining the exiting field with >>> a different data type, but it added a new column to the database table >>> instead of altering it. >>> >>> Thanks, >>> >>> Raj >>> >>> >> > |
Hi Scot,
I agree it would be very critical to alter column on a production database. At the same time, I don't think someone will alter the schema of a production system without knowing the consequences. However, It can be helpful in some cases during development where a minor change in the schema is required for example in my case, I want to change the type of weightUnitPrice on ShipmentCostEstimate from currency-amount to currency-precise. Making the change in base entity will bring the pain of merging every time I merge the SVN branch to my local branch. Thanks, Raj Scott Gray wrote: > Hi Raj > > I don't think a solution for this would be straightforward, ofbiz wouldn't > want to alter a column automatically because of the potential for data loss. > > Regards > Scott > > 2008/5/18 Raj Saini <[hidden email]>: > > >> Jacques, >> >> Thanks for the pointer. Should I create a Jira issue and may be I can pick >> it up when I understand the entity engine stuff clearly. >> >> Thanks, >> >> Raj >> >> Jacques Le Roux wrote: >> >> >>> Raj, >>> >>> If you look into ModelEntity.java you will find this comment >>> // TODO: should we look for existing fields of the same name here? for now >>> just add to list... >>> >>> Maybe someone will enchance it one day.... >>> >>> Jacques >>> >>> From: "Raj Saini" <[hidden email]> >>> >>> >>>> Hi, >>>> >>>> Is there a way to extend the field type of a entity using extend-entity >>>> or any other similar mechanism without modifying the original entity >>>> definition. I tried using extend-entity by redefining the exiting field with >>>> a different data type, but it added a new column to the database table >>>> instead of altering it. >>>> >>>> Thanks, >>>> >>>> Raj >>>> >>>> >>>> > > |
In reply to this post by rajsaini
enities fields are the same as columns in table.
each Database has the conversion table for what each field type is. by changing this you can very the type of column and size. look in framework/entity/fieldtype Raj Saini sent the following on 5/16/2008 10:45 PM: > Hi, > > Is there a way to extend the field type of a entity using extend-entity > or any other similar mechanism without modifying the original entity > definition. I tried using extend-entity by redefining the exiting field > with a different data type, but it added a new column to the database > table instead of altering it. > > Thanks, > > Raj > > |
In reply to this post by rajsaini
I guess there's no reason why extend-entity shouldn't work the same as if
you changed the entity definition itself, I still don't think it should be responsible for changing the database columns though. Regards Scott 2008/5/18 Raj Saini <[hidden email]>: > Hi Scot, > > I agree it would be very critical to alter column on a production database. > At the same time, I don't think someone will alter the schema of a > production system without knowing the consequences. > > However, It can be helpful in some cases during development where a minor > change in the schema is required for example in my case, I want to change > the type of weightUnitPrice on ShipmentCostEstimate from currency-amount to > currency-precise. Making the change in base entity will bring the pain of > merging every time I merge the SVN branch to my local branch. > > Thanks, > > Raj > > > > Scott Gray wrote: > >> Hi Raj >> >> I don't think a solution for this would be straightforward, ofbiz wouldn't >> want to alter a column automatically because of the potential for data >> loss. >> >> Regards >> Scott >> >> 2008/5/18 Raj Saini <[hidden email]>: >> >> >> >>> Jacques, >>> >>> Thanks for the pointer. Should I create a Jira issue and may be I can >>> pick >>> it up when I understand the entity engine stuff clearly. >>> >>> Thanks, >>> >>> Raj >>> >>> Jacques Le Roux wrote: >>> >>> >>> >>>> Raj, >>>> >>>> If you look into ModelEntity.java you will find this comment >>>> // TODO: should we look for existing fields of the same name here? for >>>> now >>>> just add to list... >>>> >>>> Maybe someone will enchance it one day.... >>>> >>>> Jacques >>>> >>>> From: "Raj Saini" <[hidden email]> >>>> >>>> >>>> >>>>> Hi, >>>>> >>>>> Is there a way to extend the field type of a entity using >>>>> extend-entity >>>>> or any other similar mechanism without modifying the original entity >>>>> definition. I tried using extend-entity by redefining the exiting field >>>>> with >>>>> a different data type, but it added a new column to the database table >>>>> instead of altering it. >>>>> >>>>> Thanks, >>>>> >>>>> Raj >>>>> >>>>> >>>>> >>>>> >>>> >> >> > > |
Free forum by Nabble | Edit this page |