排除由休眠创建的特定 table?

Exclude a specific table from being created by hibernate?

我有一个映射到视图的 @Entity,这是它的外观

import org.hibernate.annotations.Immutable;
import javax.persistence.*;

@Table(name = "user_earning")
@Entity
@Immutable
public class UserFlightEarning {
    @Id public Long userId;
    public Long flightId;
    @Column(name = "flight_seq") public Long flightSequence;
}

这很好用,我可以使用 dao 从视图中检索记录。但是我在日志中注意到 Hibernate 实际上正在尝试创建 table 但失败了,因为它已经存在。

2015-11-12 21:56:34.841 ERROR 4204 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: create table user_profile (user_id bigint not null, avg_airtime integer, avg_fuel_points integer, avg_miles integer, email varchar(255), first_name varchar(255), flights_count integer, furthest_flight integer, last_name varchar(255), longest_flight integer, most_visited_city varchar(255), tier_end integer, tier_start integer, primary key (user_id)) 2015-11-12 21:56:34.841 ERROR 4204 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'user_profile' already exists

我可以配置休眠以使其跳过此类实体的创建吗?我以为 @Immutable 注释告诉 Hibernate 跳过创建,但似乎这个注释只是为了防止对 table.

的 crud 操作

@Subselect 注释是 Hibernate 中唯一阻止为 @Entity 创建相应的 table 的注释:

@Entity
@Subselect("select * from user_earning")
public class UserFlightEarning {

    @Id 
    public Long userId;

    public Long flightId;

    @Column(name = "flight_seq") 
    public Long flightSequence;
}