作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有2个MYSQL表
表1
id bigint auto increment Primary Key
type Enum ('vegetable','fruit')
color Enum ('green','red','yellow')
表2
id bigint (same as the id in Table 1)
sweet boolean
sour boolean
.. other fields specific to type fruit
现在我正在创建 3 个对象,首先是父类
@Entity
@Configurable
@Table(name = "table1")
@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING)
public class ParentClass {
..
}
现在是蔬菜二等
@Entity
@Configurable
@DiscriminatorValue("vegetable")
@DiscriminatorColumn(name = "color", discriminatorType = DiscriminatorType.STRING)
public class Vegetable extends Parent{
..
}
第三,水果类
@Entity
@Configurable
@SecondaryTables({ @SecondaryTable(name = "table2",
pkJoinColumns = { @PrimaryKeyJoinColumn(name = "id", referencedColumnName = "id") }) })
@DiscriminatorValue("fruit")
@DiscriminatorColumn(name = "color", discriminatorType = DiscriminatorType.STRING)
public class Fruit extends Parent{
..
}
我需要第二个鉴别器在蔬菜和水果上添加更多继承类(6 个其他类),例如,
@Entity
@Configurable
@DiscriminatorValue("red")
public class RedVegetable extends Vegetable{
..
}
@Entity
@Configurable
@DiscriminatorValue("green")
public class GreenFruit extends Fruit{
..
}
等等。
Hibernate 不允许我这样做。我的设计有什么问题吗?提前致谢!
最佳答案
了解到这在 Hibernate 中无法完成。因此找到了一种替代方法,通过合并 table1 中的判别器 friend ,例如 Enum('fruit|red'、'fruit|green'、'vegetable|red'.. 等)。如果我错了,请纠正我。
关于java - Hibernate 继承类上的嵌套鉴别器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29239670/
我写了一段代码,在比特流中连续 6 个“1”后添加一个“0”。但是如何解码呢? 这里是一个比特流的例子: original = {01101111110111000101111110001100...
我是一名优秀的程序员,十分优秀!