How to update multiple entities (1000) in jmix

How can i update multiple entities in jmix. In cuba i was using entity manage and query. Do i have to use for loop only or any another way?

The most native to Jmix way to manipulate entities is DataManager. When you use it, you can be sure all Jmix features work properly: access control, entity events, audit.

You can pass all your entities at once to save them in one transaction, see the docs.

For example:, customer2, order1);

List<Customer> customers = Arrays.asList(customer1, customer2); SaveContext().saving(customers, order1));

If your collection of entities is too large, split it to chunks and use a loop to save in separate calls to DataManager.

Thats exactly I am doing presently using ‘for loop’, but whether it will affect performance or server load. In cuba running native sql queries was fast for even 10000 records (my experience)

Whether down the line we will be able to run native sql in jmix?


Sure you can run native queries in Jmix.

Use EntityManager or Spring’s JdbcTemplate, for example:

    private DataSource dataSource;
    public void executeSql() {
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
        // ...

See also this hint for improving performance of data saving: DataManager save function's effeciency too low