Can't get a Relation to Create a FK Constraint

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Can't get a Relation to Create a FK Constraint

Forrest Rae
Hi Everyone,

I'm having a heck of a time trying to get this to work.  I have a list
of business specific codes I want to apply to a quote.  It's a large
list that changes, so Enumeration wouldn't be right for me here.

For the life of me, I can not figure out why there is no foreign key
constraint created in the Postgres database for the relation on Quote.
I'm using a database that has some quote data in it already, but I did
try deleting all the quote records, extending the entity, and then
adding the records back in via <entity-engine-xml>.

Nothing I've tried results in a FK constraint being created at the
database level.  Any ideas?

<entity entity-name="MyCode"
    package-name="org.ofbiz.common.my"
    title="Classification Code Data Object Entity">
  <field name="code" type="id-ne"></field>
  <field name="description" type="description"></field>
  <field name="fromDate" type="date-time"></field>
  <field name="thruDate" type="date-time"></field>
  <prim-key field="code"/>
</entity>

<extend-entity entity-name="Quote">
  <field name="myCode" type="id-ne" not-null="true"/>
  <relation type="one" fk-name="QUOTE_MY" rel-entity-name="MyCode">
    <key-map field-name="myCode" rel-field-name="code"/>
  </relation>
</extend-entity>

-Forrest
Reply | Threaded
Open this post in threaded view
|

Re: Can't get a Relation to Create a FK Constraint

Christian Carlow-OFBizzer
Hey Forrest,

I confirm this same issue on the trunk.  It seems foreign keys are not
currently handled by extend-entity.  I encountered this issue a while
back but didn't to create an issue for it and manually created the
relation in the database server.

+1 to create a JIRA

On Tue, 2015-06-09 at 17:20 -0700, Forrest Rae wrote:

> Hi Everyone,
>
> I'm having a heck of a time trying to get this to work.  I have a list
> of business specific codes I want to apply to a quote.  It's a large
> list that changes, so Enumeration wouldn't be right for me here.
>
> For the life of me, I can not figure out why there is no foreign key
> constraint created in the Postgres database for the relation on Quote.
> I'm using a database that has some quote data in it already, but I did
> try deleting all the quote records, extending the entity, and then
> adding the records back in via <entity-engine-xml>.
>
> Nothing I've tried results in a FK constraint being created at the
> database level.  Any ideas?
>
> <entity entity-name="MyCode"
>     package-name="org.ofbiz.common.my"
>     title="Classification Code Data Object Entity">
>   <field name="code" type="id-ne"></field>
>   <field name="description" type="description"></field>
>   <field name="fromDate" type="date-time"></field>
>   <field name="thruDate" type="date-time"></field>
>   <prim-key field="code"/>
> </entity>
>
> <extend-entity entity-name="Quote">
>   <field name="myCode" type="id-ne" not-null="true"/>
>   <relation type="one" fk-name="QUOTE_MY" rel-entity-name="MyCode">
>     <key-map field-name="myCode" rel-field-name="code"/>
>   </relation>
> </extend-entity>
>
> -Forrest


Reply | Threaded
Open this post in threaded view
|

Re: Can't get a Relation to Create a FK Constraint

Jacques Le Roux
Administrator
Le 10/06/2015 08:05, Christian Carlow a écrit :
> Hey Forrest,
>
> I confirm this same issue on the trunk.  It seems foreign keys are not
> currently handled by extend-entity.  I encountered this issue a while
> back but didn't to create an issue for it and manually created the
> relation in the database server.
>
> +1 to create a JIRA

Yes please. Last year I added the possibility to enlarge the PKs lengths. I don't think it's related but I will check.

A good way to check if it's a regression is to test with the current stable. Else it's an improvement. Could you please try that 1st?

Jacques

>
> On Tue, 2015-06-09 at 17:20 -0700, Forrest Rae wrote:
>> Hi Everyone,
>>
>> I'm having a heck of a time trying to get this to work.  I have a list
>> of business specific codes I want to apply to a quote.  It's a large
>> list that changes, so Enumeration wouldn't be right for me here.
>>
>> For the life of me, I can not figure out why there is no foreign key
>> constraint created in the Postgres database for the relation on Quote.
>> I'm using a database that has some quote data in it already, but I did
>> try deleting all the quote records, extending the entity, and then
>> adding the records back in via <entity-engine-xml>.
>>
>> Nothing I've tried results in a FK constraint being created at the
>> database level.  Any ideas?
>>
>> <entity entity-name="MyCode"
>>      package-name="org.ofbiz.common.my"
>>      title="Classification Code Data Object Entity">
>>    <field name="code" type="id-ne"></field>
>>    <field name="description" type="description"></field>
>>    <field name="fromDate" type="date-time"></field>
>>    <field name="thruDate" type="date-time"></field>
>>    <prim-key field="code"/>
>> </entity>
>>
>> <extend-entity entity-name="Quote">
>>    <field name="myCode" type="id-ne" not-null="true"/>
>>    <relation type="one" fk-name="QUOTE_MY" rel-entity-name="MyCode">
>>      <key-map field-name="myCode" rel-field-name="code"/>
>>    </relation>
>> </extend-entity>
>>
>> -Forrest
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Can't get a Relation to Create a FK Constraint

Christian Carlow-OFBizzer
Hey Jacques,

Its not supported for 13.07 either.  Created JIRA as improvement:
https://issues.apache.org/jira/browse/OFBIZ-6493

On Wed, 2015-06-10 at 09:49 +0200, Jacques Le Roux wrote:

> Le 10/06/2015 08:05, Christian Carlow a écrit :
> > Hey Forrest,
> >
> > I confirm this same issue on the trunk.  It seems foreign keys are not
> > currently handled by extend-entity.  I encountered this issue a while
> > back but didn't to create an issue for it and manually created the
> > relation in the database server.
> >
> > +1 to create a JIRA
>
> Yes please. Last year I added the possibility to enlarge the PKs lengths. I don't think it's related but I will check.
>
> A good way to check if it's a regression is to test with the current stable. Else it's an improvement. Could you please try that 1st?
>
> Jacques
>
> >
> > On Tue, 2015-06-09 at 17:20 -0700, Forrest Rae wrote:
> >> Hi Everyone,
> >>
> >> I'm having a heck of a time trying to get this to work.  I have a list
> >> of business specific codes I want to apply to a quote.  It's a large
> >> list that changes, so Enumeration wouldn't be right for me here.
> >>
> >> For the life of me, I can not figure out why there is no foreign key
> >> constraint created in the Postgres database for the relation on Quote.
> >> I'm using a database that has some quote data in it already, but I did
> >> try deleting all the quote records, extending the entity, and then
> >> adding the records back in via <entity-engine-xml>.
> >>
> >> Nothing I've tried results in a FK constraint being created at the
> >> database level.  Any ideas?
> >>
> >> <entity entity-name="MyCode"
> >>      package-name="org.ofbiz.common.my"
> >>      title="Classification Code Data Object Entity">
> >>    <field name="code" type="id-ne"></field>
> >>    <field name="description" type="description"></field>
> >>    <field name="fromDate" type="date-time"></field>
> >>    <field name="thruDate" type="date-time"></field>
> >>    <prim-key field="code"/>
> >> </entity>
> >>
> >> <extend-entity entity-name="Quote">
> >>    <field name="myCode" type="id-ne" not-null="true"/>
> >>    <relation type="one" fk-name="QUOTE_MY" rel-entity-name="MyCode">
> >>      <key-map field-name="myCode" rel-field-name="code"/>
> >>    </relation>
> >> </extend-entity>
> >>
> >> -Forrest
> >
> >