Cannot insert into Mendix Table using Database Connector

-1
I cannot insert new record to a Mendix table using Database Connector since it is complaining that the ID column cannot be null. Should Database Connector automatically create a value for ID column? 
asked
6 answers
3

You should never directly work on the Mendix tables. Mendix is managing all the IDs. Changing something by not doing that via Mendix runtime can cause errors.

What is your usecase? I am pretty sure there is a solution that does not need the help of database connector.

answered
1

Hi  Andreas,

The use case requires our Mendix based application to copy data from external applications. This is on a regular basis. I initially used Database Connector/Excel Import for initial data. I cannot do this step on a regular basis, hence the need to use a loader that copies data from external to Mendix tables. 

 

Is there an alternative way of doing this? 

answered
1

Hi,

so you need to retrieve data from an external database and store it in your mendix database. You could use database connector to retrieve the data from the external database. Now you have a list of objects in your microflow. Iterate over this list, creat objects from your domain model, copy the information to those objects and commit them. No need to insert data into your mendix database by using database connector.

answered
1

Hi Andreas, 

That is what I am currently doing but I am seeing a performance issue on it. I am loading at a minimum 5000 new rows and it is taking time to create all those objects. I also have experience a scenario where Mendix timeout processing the thousand rows. 

answered
1

I highly recommend doing it in batches.

There are multiple best practices.

  1. Never commit in a loop. Create a list and add your created objects to that list, so that you can commit the list in one step.
  2. Work in batches. Don’t do everything at once. Create a batch of a few hundred → commit → next batch → commit …

If it is still too much, you may need to make use of the process queue to ensure that your jobs run in different transactions.

answered
1

Hi Andreas,

Thanks for the tip and I will give it a try. 

answered