这是我在 stackoverflow 中的第一个查询,我想我提供了所有必要的输入:
我在下面提供了我的 Java bean 和数据库表的详细信息:
******Java Bean 类:***
import java.sql.Timestamp;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "BANK_MESSAGES")
public class messagesBean implements Serializable
{
@Id
@Column(name="msg_id")
private String msg_id;
@Column(name="msg_date")
Timestamp msgDateTime;
@Column(name="message")
private byte[] message;
@Column(name="msg_type")
private String msg_type;
//Getters and Setters for the above fields
}
下面是我的数据库表 (Oracle) 的 DDL:
create table BANK_MESSAGES
(msg_id varchar2(10),
msg_date timestamp,
message blob,
msg_type varchar2(5)) ;
我想了解像上面这样映射到数据库表的 bean 在 hibernate 中的默认继承策略是什么?
最佳答案
如果您只有一个实体而没有任何子类,那么继承是无关紧要的。
否则,the javadoc有答案:
Annotation Type
Inheritance
@Target(value=TYPE) @Retention(value=RUNTIME) public @interface Inheritance
Defines the inheritance strategy to be used for an entity class hierarchy. It is specified on the entity class that is the root of the entity class hierarchy. If the Inheritance annotation is not specified or if no inheritance type is specified for an entity class hierarchy, the SINGLE_TABLE mapping strategy is used.
(强调我的)。
关于java - 对于映射到数据库表的 bean,hibernate 中的默认继承策略是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31746666/