Set MSSQL View to Layout

Is possible to create screen from Sql View without creating entity? I wish create screen by query and manage it from SQL.
With Regards


without having tried it, i would assume that it will work but not without creating an entity. In the table annotation of the entity you can use the name of the SQL view. Since the OR-Mapper doesn’t really care it the table is really a table or a view, it should work in the read case. Of course, you can’t write to it, but since you want to to manage the data via sql, it shouldn’t be a problem.

You just have to remove the studio table generation scripts to not create a table with the same name…


1 Like

Hi, I have the same problem. I 've done the same way like Mario described…

Now to the next problem:
If you create an entity or change an entity cuba generate new sql-init-scripts, every time. The create table for the db-view-entity is also created every time. How should I exclude the entity from sql-init-script creation?

Best regards, Matthias

HI, sorry for the late answer.

Special logic intended to prevent scripts generation for DB-views is implemented in Studio.

In my test project on MSSQL it works well: I just create a new entity with the appropriate Id type*, adjust the *@Table to the name of the view, and no scripts are generated for the entity. The value of the @Table should be specified without a schema prefix.

@Table(name = "SOMETABLE")
@Entity(name = "test$SomeTable")
public class SomeTable extends BaseIntegerIdEntity {
    private static final long serialVersionUID = -3623967799921597093L;

    @Column(name = "SOME_FIELD", length = 50)
    protected String springField;

If the probem persists, please describe what exactly you do.