Error Studio v. 11.3 trying to create foreign keys over database views

Hi Cuba’s support friends,

Next reported error haven’t been solved yet and customers who develop new Cuba application modules that live together with legacy applications have to modify ever all the database scripts of constraint creation over database views:

https://www.cuba-platform.com/discuss/t/error-in-studio-v-8-1-trying-to-create-foreing-keys-towards-database-views/8541

As I explained in the topic above, this improvement was implemented in Studio 6.x and dissapeared in Studio 8.1.

Is it possible to introduce in roadmap of Studio’s future versions the solution of this error?

Thank you in advance

Hi, @xlorentep!

Are you using the latest version 11.3-183 of the CUBA plugin?

An entity that is a DB view has DesignSupport anotation with parameters - “{‘dbView’:true,‘imported’:true,‘generateDdl’:false}”? Or in Entity Designer select DB View checkbox
image

Hi, Alexander

Yes, I’m using the latest version 11.3-183 of the Cuba plugin.

I was thinking why this functionality it doesn’t work properly and there is a peculiarity that could be the key an I would explain.

There is a Cuba Studio project that only contains all the entities that are DB view of the master tables of the legacy application, with the right configuration that you mentioned:

package com.company.mestrelegacy.entity;

import javax.persistence.Entity;
import javax.persistence.Table;
import com.haulmont.cuba.core.global.DesignSupport;
import java.math.BigDecimal;
import javax.persistence.Column;
import com.haulmont.cuba.core.entity.BaseIntegerIdEntity;
import com.haulmont.chile.core.annotations.NamePattern;

@NamePattern("%s|proNom")
@DesignSupport("{'dbView':true,'imported':true,'generateDdl':false}")
@Table(name = "Proveidor")
@Entity(name = "mestrelegacy$Proveidor")
public class Proveidor extends BaseIntegerIdEntity {

package com.company.mestrelegacy.entity;

import javax.persistence.Entity;
import javax.persistence.Table;
import com.haulmont.cuba.core.global.DesignSupport;
import javax.persistence.Column;
import com.haulmont.cuba.core.entity.BaseIntegerIdEntity;
import com.haulmont.chile.core.annotations.NamePattern;

@NamePattern("%s|diDes")
@DesignSupport("{'dbView':true,'imported':true,'generateDdl':false}")
@Table(name = "Divisa")
@Entity(name = "mestrelegacy$Divisa")
public class Divisa extends BaseIntegerIdEntity {

Then, there are antother Cuba Projects for different application modules that use the entities mapped to the DB View as an Application module.

When Cuba Studio generates the database scripts to generate foreign keys over database views happens in projects with entites defined in the data model of this project which have foreign keys relation to entites that belong to the Application module.

Could be this situation the cause of the problem?

Regards,

I think I understand what the problem is.

The problem is that the ‘DesignSupport’ annotation has ‘RetentionPolicy.SOURCE’ retention and is not present in compiled classes.
I will change the retention for the annotation, and also change the search engine in the Studio.

See: https://youtrack.cuba-platform.com/issue/STUDIO-6914

Congratulations, Alexander.

With release 12, now Studio doesn’t create the DB scripts for adding constraints to DB view entities that belongs an Application module although it still creating this kind of script for DB view entities that are defined on the same project.

image

image

image

I hope you can solve it.

Best regards

Do you have MANY_TO_MANY association between FacturaProv(has a persistent entity) and ContractLin (DB view)?

Yes, Alexander, I’ve got a MANY_TO_MANY association as you can see on next image:
image

Fixed in a next bug fix release https://youtrack.cuba-platform.com/issue/STUDIO-7232