pre*_*oid 14 spring hibernate jpa spring-data
我有一个@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;
}
Run Code Online (Sandbox Code Playgroud)
这很好用,我可以使用dao从视图中检索记录.但是我在日志中注意到Hibernate实际上是在尝试创建表但由于它已经存在而失败.
2015-11-12 21:56:34.841 ERROR 4204 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport:HHH000389:不成功: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:表'user_profile'已经存在
我可以配置hibernate,以便跳过这些实体的创建吗?我认为@Immutable
注释告诉Hibernate跳过创建,但似乎这个注释只是为了防止表上的crud操作.
Tob*_*fke 17
该@Subselect
注释是否处于休眠唯一注释防止相应的表的创建用于@Entity
:
@Entity
@Subselect("select * from user_earning")
public class UserFlightEarning {
@Id
public Long userId;
public Long flightId;
@Column(name = "flight_seq")
public Long flightSequence;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4447 次 |
最近记录: |