2Pack error:"org.adempiere.exceptions.DBException: org.postgresql.util.PSQLException: ERROR: foreign key constraint ..."

81 views
Skip to first unread message

Peter Shepetko

unread,
Apr 2, 2019, 8:49:13 AM4/2/19
to iDempiere
Hi Community! 
When I use in my 2Pack Reference=Table(or Search) and Reference Key=C_UOM I had error: 

 org.adempiere.exceptions.DBException: org.postgresql.util.PSQLException: ERROR: foreign key constraint "volumeuom_ddfreightline" cannot be implemented
Detail: Key columns "c_uom_id" and "volume_uom_id" are of incompatible types: numeric and character varying. 

I solved it when used RED1's patch  FKConstraintCheckID.patch from ticket IDEMPIERE-1264.
Thanks RED1!

When I will publish new plugin all users will have this error because this patch is not exist in the core.

This ticket IDEMPIERE-1264 have Status=Open and maybe need to add this patch to core.

Best regards,
Peter

Heng Sin Low

unread,
Apr 2, 2019, 10:44:49 AM4/2/19
to idem...@googlegroups.com
the datatype for your volumn_uom_ID column is wrong - it should have the same datatype as C_UOM_ID

--
You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/2fe04791-c7c4-40d2-9a18-8fdea6e88298%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Carlos Antonio Ruiz Gomez

unread,
Apr 2, 2019, 10:56:16 AM4/2/19
to idem...@googlegroups.com
Agree with Heng Sin, the error indicates there is a problem with your dictionary, and the patch is just hiding it, correct solution must be to fix your dictionary problem.

If the patch works is probably because your columns end with _id in lowercase instead of uppercase as the patch expects.

That patch seems incorrect, I'll add the comment on the ticket.

Regards,

Carlos Ruiz


El 2/04/19 a las 16:44, Heng Sin Low escribió:

Peter Shepetko

unread,
Apr 3, 2019, 7:14:56 AM4/3/19
to iDempiere
Hi Carlos and Hengsin!
Thanks for your answers, but I checked it a lot time.
I created short example 2pack for demo because maybe I had mistake when created 2pack and you can correct me.
Step-by-step my example:
Step 1)Crete table in Postgresql with new field volume_uom_id numeric(10,0)
CREATE TABLE test2
(
  test2_id numeric(10,0) NOT NULL,
  ad_client_id numeric(10,0) NOT NULL,
  ad_org_id numeric(10,0) NOT NULL,
  isactive character(1) NOT NULL DEFAULT 'Y'::bpchar,
  created timestamp without time zone NOT NULL DEFAULT now(),
  createdby numeric(10,0) NOT NULL,
  updated timestamp without time zone NOT NULL DEFAULT now(),
  updatedby numeric(10,0) NOT NULL,
  name character varying(60) NOT NULL,
  volume_uom_id numeric(10,0)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE test2
  OWNER TO adempiere; 
Step 2) Create  new table Test2 in iDempiere
Step 3) For field  volume_uom_id set 
Reference*=Table
Reference Key=C_UOM
Step 4)  Create window for this table.
Step 5)  Create 2Pack=Test2.zip for this window (you can see this file in attachment)
Step 6) Pack In this 2Pack=Test2.zip on the server with RED1 path and OK. 
Step 7)  Pack In this 2Pack=Test2.zip on the server https://experimental.idempiere.org/webui/ and have the same error :
org.adempiere.exceptions.DBException: org.postgresql.util.PSQLException: ERROR: foreign key constraint "volumeuom_test2" cannot be implemented
  Detail: Key columns "volume_uom_id" and "c_uom_id" are of incompatible types: character varying and numeric.
You can check it on the server https://experimental.idempiere.org/webui/ .

Thanks,
Peter


 
вторник, 2 апреля 2019 г., 17:56:16 UTC+3 пользователь Carlos Antonio Ruiz Gomez написал:
Test2.zip

Carlos Antonio Ruiz Gomez

unread,
Apr 3, 2019, 7:48:32 AM4/3/19
to idem...@googlegroups.com
Hi Peter, as I suspected, your columnname is volume_uom_id and it must be volume_uom_ID - or to be more consistent with iDempiere naming conventions would Volume_UOM_ID

I edited the 2pack to change the _ID ending to uppercase and imported in the same server successfully.

The patch is just hiding that a column that is intended to be numeric was created as varchar because of the wrong naming convention.

Regards,

Carlos Ruiz


El 3/04/19 a las 13:14, Peter Shepetko escribió:

Peter Shepetko

unread,
Apr 3, 2019, 8:34:46 AM4/3/19
to idem...@googlegroups.com
Thanks Carlos,
 I agree that my mistake when I create field from DB by process, I must change name of field.

Regards,
Peter

ср, 3 апр. 2019 г. в 14:48, Carlos Antonio Ruiz Gomez <car...@gmail.com>:
--
You received this message because you are subscribed to a topic in the Google Groups "iDempiere" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/idempiere/kCcIkxZx3-A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/e0bf9347-6692-b3b9-de7c-cebe4096739a%40gmail.com.
Reply all
Reply to author
Forward
0 new messages