Hello All:
Is this possible: can I create an entity without a primary key? TIA Ruth |
Did you try defining it as an empty prim-key group?
ie <prim-key field=""/> As far as the entitymodel.xsd, "prim-key" is a required element and the attribute "field" is required --- Ruth Hoffman <[hidden email]> wrote: > Hello All: > Is this possible: can I create an entity without a > primary key? > > TIA > Ruth > |
Hi Chis:
I did not try that - due to my ignorance of how to read an xsd. However, I just tried it and I get the following error (from the error log) while OFBiz attempts to create the new entity, on startup: Getting Table Info From Database 17327 (main) [ DatabaseUtil.java:356:WARN ] Entity [cdrdata] has no table in the database 17377 (main) [ DatabaseUtil.java:364:ERROR] Could not create table [public.CDRDATA]: SQL Exception while executing the following: CREATE TABLE public.CDRDATA (CALL_SN SERIAL, CORRELATION_ID INT4, ....[left some of the field defs out]... MATCHED_FLAG CHAR(1), CONSTRAINT PK_CDRDATA PRIMARY KEY ()) Error was: java.sql.SQLException: ERROR: syntax error at or near ")" This is the same error I was getting when I had no prim-key element. The only thing that makes this go "away" is to set one of the fields to a primary key field. Since I'm trying to mimic a real life database table that has no primary key, (mostly for off-line testing of my application), it would be desirable not to have a primary key field. I'm just wondering if I forgot to set something else - somewhere else? Thanks for your suggestion. I learned something new and I think I'll go back and try to understand how the xsd can help me troubleshoot future problems. Regards, Ruth Chris Howe wrote: >Did you try defining it as an empty prim-key group? > >ie <prim-key field=""/> > >As far as the entitymodel.xsd, "prim-key" is a >required element and the attribute "field" is required > >--- Ruth Hoffman <[hidden email]> wrote: > > > >>Hello All: >>Is this possible: can I create an entity without a >>primary key? >> >>TIA >>Ruth >> >> >> > > > > |
try changing "use-pk-contraint-names" to false in your
datasource information. ie in <datasource name="localderbyodbc" helper-class="org.ofbiz.entity.datasource.GenericHelperDAO" schema-name="OFBIZ" field-type-name="derby" check-on-start="true" add-missing-on-start="true" use-pk-constraint-names="false"> <!-- Right here --> ... </datasource> --- Ruth Hoffman <[hidden email]> wrote: > Hi Chis: > I did not try that - due to my ignorance of how to > read an xsd. However, > I just tried it and I get the following error (from > the error log) while > OFBiz attempts to create the new entity, on startup: > > Getting Table Info From Database > 17327 (main) [ DatabaseUtil.java:356:WARN > ] Entity [cdrdata] > has no table in the database > 17377 (main) [ > DatabaseUtil.java:364:ERROR] Could not create > table [public.CDRDATA]: SQL Exception while > executing the following: > CREATE TABLE public.CDRDATA (CALL_SN SERIAL, > CORRELATION_ID INT4, > ....[left some of the field defs out]... > MATCHED_FLAG CHAR(1), > CONSTRAINT PK_CDRDATA PRIMARY KEY ()) > Error was: java.sql.SQLException: ERROR: syntax > error at or near ")" > > This is the same error I was getting when I had no > prim-key element. The > only thing that makes this go "away" is to set one > of the fields to a > primary key field. Since I'm trying to mimic a real > life database table > that has no primary key, (mostly for off-line > testing of my > application), it would be desirable not to have a > primary key field. I'm > just wondering if I forgot to set something else - > somewhere else? > > Thanks for your suggestion. I learned something new > and I think I'll go > back and try to understand how the xsd can help me > troubleshoot future > problems. > > Regards, > Ruth > > > Chris Howe wrote: > > >Did you try defining it as an empty prim-key group? > > > >ie <prim-key field=""/> > > > >As far as the entitymodel.xsd, "prim-key" is a > >required element and the attribute "field" is > required > > > >--- Ruth Hoffman <[hidden email]> wrote: > > > > > > > >>Hello All: > >>Is this possible: can I create an entity without a > >>primary key? > >> > >>TIA > >>Ruth > >> > >> > >> > > > > > > > > > |
Hi Chris:
Just tried that and I still get the identical error. If it makes any difference, I've tried this with both Derby & Postgres - with the same results. I'm wondering if it is possible to do this? If not, its ok, I can work around it. But it would be nice to know and document if it is a restriction. Thanks again for you suggestions. Ruth Chris Howe wrote: >try changing "use-pk-contraint-names" to false in your >datasource information. > >ie in ><datasource name="localderbyodbc" >helper-class="org.ofbiz.entity.datasource.GenericHelperDAO" >schema-name="OFBIZ" >field-type-name="derby" >check-on-start="true" >add-missing-on-start="true" >use-pk-constraint-names="false"> <!-- Right here --> >... ></datasource> > >--- Ruth Hoffman <[hidden email]> wrote: > > > >>Hi Chis: >>I did not try that - due to my ignorance of how to >>read an xsd. However, >>I just tried it and I get the following error (from >>the error log) while >>OFBiz attempts to create the new entity, on startup: >> >> Getting Table Info From Database >> 17327 (main) [ DatabaseUtil.java:356:WARN >>] Entity [cdrdata] >> has no table in the database >> 17377 (main) [ >>DatabaseUtil.java:364:ERROR] Could not create >> table [public.CDRDATA]: SQL Exception while >>executing the following: >> CREATE TABLE public.CDRDATA (CALL_SN SERIAL, >>CORRELATION_ID INT4, >> ....[left some of the field defs out]... >>MATCHED_FLAG CHAR(1), >> CONSTRAINT PK_CDRDATA PRIMARY KEY ()) >> Error was: java.sql.SQLException: ERROR: syntax >>error at or near ")" >> >>This is the same error I was getting when I had no >>prim-key element. The >>only thing that makes this go "away" is to set one >>of the fields to a >>primary key field. Since I'm trying to mimic a real >>life database table >>that has no primary key, (mostly for off-line >>testing of my >>application), it would be desirable not to have a >>primary key field. I'm >>just wondering if I forgot to set something else - >>somewhere else? >> >>Thanks for your suggestion. I learned something new >>and I think I'll go >>back and try to understand how the xsd can help me >>troubleshoot future >>problems. >> >>Regards, >>Ruth >> >> >>Chris Howe wrote: >> >> >> >>>Did you try defining it as an empty prim-key group? >>> >>>ie <prim-key field=""/> >>> >>>As far as the entitymodel.xsd, "prim-key" is a >>>required element and the attribute "field" is >>> >>> >>required >> >> >>>--- Ruth Hoffman <[hidden email]> wrote: >>> >>> >>> >>> >>> >>>>Hello All: >>>>Is this possible: can I create an entity without a >>>>primary key? >>>> >>>>TIA >>>>Ruth >>>> >>>> >>>> >>>> >>>> >>> >>> >>> >>> > > > > |
Are you sure it was identical? Particularly around
CONSTRAINT PK_CDRDATA PRIMARY KEY ()) --- Ruth Hoffman <[hidden email]> wrote: > Hi Chris: > Just tried that and I still get the identical error. > If it makes any > difference, I've tried this with both Derby & > Postgres - with the same > results. I'm wondering if it is possible to do this? > If not, its ok, I > can work around it. But it would be nice to know and > document if it is a > restriction. > > Thanks again for you suggestions. > Ruth > > Chris Howe wrote: > > >try changing "use-pk-contraint-names" to false in > your > >datasource information. > > > >ie in > ><datasource name="localderbyodbc" > >helper-class="org.ofbiz.entity.datasource.GenericHelperDAO" > >schema-name="OFBIZ" > >field-type-name="derby" > >check-on-start="true" > >add-missing-on-start="true" > >use-pk-constraint-names="false"> <!-- Right here > --> > >... > ></datasource> > > > >--- Ruth Hoffman <[hidden email]> wrote: > > > > > > > >>Hi Chis: > >>I did not try that - due to my ignorance of how to > >>read an xsd. However, > >>I just tried it and I get the following error > (from > >>the error log) while > >>OFBiz attempts to create the new entity, on > startup: > >> > >> Getting Table Info From Database > >> 17327 (main) [ > DatabaseUtil.java:356:WARN > >>] Entity [cdrdata] > >> has no table in the database > >> 17377 (main) [ > >>DatabaseUtil.java:364:ERROR] Could not create > >> table [public.CDRDATA]: SQL Exception while > >>executing the following: > >> CREATE TABLE public.CDRDATA (CALL_SN SERIAL, > >>CORRELATION_ID INT4, > >> ....[left some of the field defs out]... > >>MATCHED_FLAG CHAR(1), > >> CONSTRAINT PK_CDRDATA PRIMARY KEY ()) > >> Error was: java.sql.SQLException: ERROR: > syntax > >>error at or near ")" > >> > >>This is the same error I was getting when I had no > >>prim-key element. The > >>only thing that makes this go "away" is to set one > >>of the fields to a > >>primary key field. Since I'm trying to mimic a > real > >>life database table > >>that has no primary key, (mostly for off-line > >>testing of my > >>application), it would be desirable not to have a > >>primary key field. I'm > >>just wondering if I forgot to set something else - > >>somewhere else? > >> > >>Thanks for your suggestion. I learned something > new > >>and I think I'll go > >>back and try to understand how the xsd can help me > >>troubleshoot future > >>problems. > >> > >>Regards, > >>Ruth > >> > >> > >>Chris Howe wrote: > >> > >> > >> > >>>Did you try defining it as an empty prim-key > group? > >>> > >>>ie <prim-key field=""/> > >>> > >>>As far as the entitymodel.xsd, "prim-key" is a > >>>required element and the attribute "field" is > >>> > >>> > >>required > >> > >> > >>>--- Ruth Hoffman <[hidden email]> wrote: > >>> > >>> > >>> > >>> > >>> > >>>>Hello All: > >>>>Is this possible: can I create an entity without > a > >>>>primary key? > >>>> > >>>>TIA > >>>>Ruth > >>>> > >>>> > >>>> > >>>> > >>>> > >>> > >>> > >>> > >>> > > > > > > > > > |
In reply to this post by Ruth Hoffman
It actually looks as if OFBiz will always add a
primary key (line 1526 of DatabaseUtil.java) when it creates the table. One hack might be to go ahead and designate a primary key for an empty table (ie no data imports on this pass), then use the sql to drop the primary key attribute for that column, remove the primary key definition (ie make it <prim-key field=""/>) then restart OFBiz --- Ruth Hoffman <[hidden email]> wrote: > Hi Chris: > Just tried that and I still get the identical error. > If it makes any > difference, I've tried this with both Derby & > Postgres - with the same > results. I'm wondering if it is possible to do this? > If not, its ok, I > can work around it. But it would be nice to know and > document if it is a > restriction. > > Thanks again for you suggestions. > Ruth > > Chris Howe wrote: > > >try changing "use-pk-contraint-names" to false in > your > >datasource information. > > > >ie in > ><datasource name="localderbyodbc" > >helper-class="org.ofbiz.entity.datasource.GenericHelperDAO" > >schema-name="OFBIZ" > >field-type-name="derby" > >check-on-start="true" > >add-missing-on-start="true" > >use-pk-constraint-names="false"> <!-- Right here > --> > >... > ></datasource> > > > >--- Ruth Hoffman <[hidden email]> wrote: > > > > > > > >>Hi Chis: > >>I did not try that - due to my ignorance of how to > >>read an xsd. However, > >>I just tried it and I get the following error > (from > >>the error log) while > >>OFBiz attempts to create the new entity, on > startup: > >> > >> Getting Table Info From Database > >> 17327 (main) [ > DatabaseUtil.java:356:WARN > >>] Entity [cdrdata] > >> has no table in the database > >> 17377 (main) [ > >>DatabaseUtil.java:364:ERROR] Could not create > >> table [public.CDRDATA]: SQL Exception while > >>executing the following: > >> CREATE TABLE public.CDRDATA (CALL_SN SERIAL, > >>CORRELATION_ID INT4, > >> ....[left some of the field defs out]... > >>MATCHED_FLAG CHAR(1), > >> CONSTRAINT PK_CDRDATA PRIMARY KEY ()) > >> Error was: java.sql.SQLException: ERROR: > syntax > >>error at or near ")" > >> > >>This is the same error I was getting when I had no > >>prim-key element. The > >>only thing that makes this go "away" is to set one > >>of the fields to a > >>primary key field. Since I'm trying to mimic a > real > >>life database table > >>that has no primary key, (mostly for off-line > >>testing of my > >>application), it would be desirable not to have a > >>primary key field. I'm > >>just wondering if I forgot to set something else - > >>somewhere else? > >> > >>Thanks for your suggestion. I learned something > new > >>and I think I'll go > >>back and try to understand how the xsd can help me > >>troubleshoot future > >>problems. > >> > >>Regards, > >>Ruth > >> > >> > >>Chris Howe wrote: > >> > >> > >> > >>>Did you try defining it as an empty prim-key > group? > >>> > >>>ie <prim-key field=""/> > >>> > >>>As far as the entitymodel.xsd, "prim-key" is a > >>>required element and the attribute "field" is > >>> > >>> > >>required > >> > >> > >>>--- Ruth Hoffman <[hidden email]> wrote: > >>> > >>> > >>> > >>> > >>> > >>>>Hello All: > >>>>Is this possible: can I create an entity without > a > >>>>primary key? > >>>> > >>>>TIA > >>>>Ruth > >>>> > >>>> > >>>> > >>>> > >>>> > >>> > >>> > >>> > >>> > > > > > > > > > |
In reply to this post by cjhowe
Hi Chris:
Here's the log file excerpt: 17716 (main) [ DatabaseUtil.java:364:ERROR] Could not create table [public.CDRDATA]: SQL Exception while executing the following: CREATE TABLE public.CDRDATA (CALL_SN SERIAL, CORRELATION_ID INT4, ....[fields deleted to protect the innocent].... MATCHED_FLAG CHAR(1), PRIMARY KEY ()) Error was: java.sql.SQLException: ERROR: syntax error at or near ")" 17722 (main) [ GenericDelegator.java:176:INFO ] Delegator "default" initializing helper "localderbyodbc" for entity group "org.ofbiz.odbc". Ruth Chris Howe wrote: >Are you sure it was identical? Particularly around >CONSTRAINT PK_CDRDATA PRIMARY KEY ()) > >--- Ruth Hoffman <[hidden email]> wrote: > > > >>Hi Chris: >>Just tried that and I still get the identical error. >>If it makes any >>difference, I've tried this with both Derby & >>Postgres - with the same >>results. I'm wondering if it is possible to do this? >>If not, its ok, I >>can work around it. But it would be nice to know and >>document if it is a >>restriction. >> >>Thanks again for you suggestions. >>Ruth >> >>Chris Howe wrote: >> >> >> >>>try changing "use-pk-contraint-names" to false in >>> >>> >>your >> >> >>>datasource information. >>> >>>ie in >>><datasource name="localderbyodbc" >>> >>> >>helper-class="org.ofbiz.entity.datasource.GenericHelperDAO" >> >> >>>schema-name="OFBIZ" >>>field-type-name="derby" >>>check-on-start="true" >>>add-missing-on-start="true" >>>use-pk-constraint-names="false"> <!-- Right here >>> >>> >>--> >> >> >>>... >>></datasource> >>> >>>--- Ruth Hoffman <[hidden email]> wrote: >>> >>> >>> >>> >>> >>>>Hi Chis: >>>>I did not try that - due to my ignorance of how to >>>>read an xsd. However, >>>>I just tried it and I get the following error >>>> >>>> >>(from >> >> >>>>the error log) while >>>>OFBiz attempts to create the new entity, on >>>> >>>> >>startup: >> >> >>>> Getting Table Info From Database >>>> 17327 (main) [ >>>> >>>> >>DatabaseUtil.java:356:WARN >> >> >>>>] Entity [cdrdata] >>>> has no table in the database >>>> 17377 (main) [ >>>>DatabaseUtil.java:364:ERROR] Could not create >>>> table [public.CDRDATA]: SQL Exception while >>>>executing the following: >>>> CREATE TABLE public.CDRDATA (CALL_SN SERIAL, >>>>CORRELATION_ID INT4, >>>> ....[left some of the field defs out]... >>>>MATCHED_FLAG CHAR(1), >>>> CONSTRAINT PK_CDRDATA PRIMARY KEY ()) >>>> Error was: java.sql.SQLException: ERROR: >>>> >>>> >>syntax >> >> >>>>error at or near ")" >>>> >>>>This is the same error I was getting when I had no >>>>prim-key element. The >>>>only thing that makes this go "away" is to set one >>>>of the fields to a >>>>primary key field. Since I'm trying to mimic a >>>> >>>> >>real >> >> >>>>life database table >>>>that has no primary key, (mostly for off-line >>>>testing of my >>>>application), it would be desirable not to have a >>>>primary key field. I'm >>>>just wondering if I forgot to set something else - >>>>somewhere else? >>>> >>>>Thanks for your suggestion. I learned something >>>> >>>> >>new >> >> >>>>and I think I'll go >>>>back and try to understand how the xsd can help me >>>>troubleshoot future >>>>problems. >>>> >>>>Regards, >>>>Ruth >>>> >>>> >>>>Chris Howe wrote: >>>> >>>> >>>> >>>> >>>> >>>>>Did you try defining it as an empty prim-key >>>>> >>>>> >>group? >> >> >>>>>ie <prim-key field=""/> >>>>> >>>>>As far as the entitymodel.xsd, "prim-key" is a >>>>>required element and the attribute "field" is >>>>> >>>>> >>>>> >>>>> >>>>required >>>> >>>> >>>> >>>> >>>>>--- Ruth Hoffman <[hidden email]> wrote: >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>>>Hello All: >>>>>>Is this possible: can I create an entity without >>>>>> >>>>>> >>a >> >> >>>>>>primary key? >>>>>> >>>>>>TIA >>>>>>Ruth >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> >>> >>> >>> >>> > > > > |
In reply to this post by cjhowe
Hi Chris:
I discovered that trick works, by accident, on one of my attempts to figure this out. Thanks again, Ruth Chris Howe wrote: >It actually looks as if OFBiz will always add a >primary key (line 1526 of DatabaseUtil.java) when it >creates the table. One hack might be to go ahead and >designate a primary key for an empty table (ie no data >imports on this pass), then use the sql to drop the >primary key attribute for that column, remove the >primary key definition (ie make it <prim-key >field=""/>) then restart OFBiz > >--- Ruth Hoffman <[hidden email]> wrote: > > > >>Hi Chris: >>Just tried that and I still get the identical error. >>If it makes any >>difference, I've tried this with both Derby & >>Postgres - with the same >>results. I'm wondering if it is possible to do this? >>If not, its ok, I >>can work around it. But it would be nice to know and >>document if it is a >>restriction. >> >>Thanks again for you suggestions. >>Ruth >> >>Chris Howe wrote: >> >> >> >>>try changing "use-pk-contraint-names" to false in >>> >>> >>your >> >> >>>datasource information. >>> >>>ie in >>><datasource name="localderbyodbc" >>> >>> >>helper-class="org.ofbiz.entity.datasource.GenericHelperDAO" >> >> >>>schema-name="OFBIZ" >>>field-type-name="derby" >>>check-on-start="true" >>>add-missing-on-start="true" >>>use-pk-constraint-names="false"> <!-- Right here >>> >>> >>--> >> >> >>>... >>></datasource> >>> >>>--- Ruth Hoffman <[hidden email]> wrote: >>> >>> >>> >>> >>> >>>>Hi Chis: >>>>I did not try that - due to my ignorance of how to >>>>read an xsd. However, >>>>I just tried it and I get the following error >>>> >>>> >>(from >> >> >>>>the error log) while >>>>OFBiz attempts to create the new entity, on >>>> >>>> >>startup: >> >> >>>> Getting Table Info From Database >>>> 17327 (main) [ >>>> >>>> >>DatabaseUtil.java:356:WARN >> >> >>>>] Entity [cdrdata] >>>> has no table in the database >>>> 17377 (main) [ >>>>DatabaseUtil.java:364:ERROR] Could not create >>>> table [public.CDRDATA]: SQL Exception while >>>>executing the following: >>>> CREATE TABLE public.CDRDATA (CALL_SN SERIAL, >>>>CORRELATION_ID INT4, >>>> ....[left some of the field defs out]... >>>>MATCHED_FLAG CHAR(1), >>>> CONSTRAINT PK_CDRDATA PRIMARY KEY ()) >>>> Error was: java.sql.SQLException: ERROR: >>>> >>>> >>syntax >> >> >>>>error at or near ")" >>>> >>>>This is the same error I was getting when I had no >>>>prim-key element. The >>>>only thing that makes this go "away" is to set one >>>>of the fields to a >>>>primary key field. Since I'm trying to mimic a >>>> >>>> >>real >> >> >>>>life database table >>>>that has no primary key, (mostly for off-line >>>>testing of my >>>>application), it would be desirable not to have a >>>>primary key field. I'm >>>>just wondering if I forgot to set something else - >>>>somewhere else? >>>> >>>>Thanks for your suggestion. I learned something >>>> >>>> >>new >> >> >>>>and I think I'll go >>>>back and try to understand how the xsd can help me >>>>troubleshoot future >>>>problems. >>>> >>>>Regards, >>>>Ruth >>>> >>>> >>>>Chris Howe wrote: >>>> >>>> >>>> >>>> >>>> >>>>>Did you try defining it as an empty prim-key >>>>> >>>>> >>group? >> >> >>>>>ie <prim-key field=""/> >>>>> >>>>>As far as the entitymodel.xsd, "prim-key" is a >>>>>required element and the attribute "field" is >>>>> >>>>> >>>>> >>>>> >>>>required >>>> >>>> >>>> >>>> >>>>>--- Ruth Hoffman <[hidden email]> wrote: >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>>>Hello All: >>>>>>Is this possible: can I create an entity without >>>>>> >>>>>> >>a >> >> >>>>>>primary key? >>>>>> >>>>>>TIA >>>>>>Ruth >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> >>> >>> >>> >>> > > > > |
Free forum by Nabble | Edit this page |