English 中文(简体)
带说明的单表单列两栏的休眠储存字段
原标题:Hibernate storing field in two columns in separate tables with annotations

我想知道 Hibertate 是否可以将一个字段存放在两个不同的表格中的两栏中。

通过 Hibertate (Hibertate )能够做到这一点吗?我知道触发器很容易。

这是我的方法;

@Entity
@Table(name = "A")
@SecondaryTable(name = "B")
public class A {
   @Id
   @Column(name = "id")
   private int id;

   // This property in both
   @AttributeOverrides({
   @AttributeOverride(column = @Column(name = "something", table = "B"), name = "something"),
   @AttributeOverride(column = @Column(name = "something", nullable = true), name = "something")})
   private int something;
}

请注意

赛达诺

最佳回答

我非常肯定它不能。我也想知道你为什么需要这样的东西, 但你只要有两个字段就可以, 并且永远确保第二个字段和第一个字段具有同样的价值:

public void setSomething(int s) {
    this.something = s:
    this.something2 = s:
}
问题回答

暂无回答




相关问题
Matrix to Represent a Triangle in Screen Space

So i have a set of four points in 3D Space. P1 [0, 0, 0] P2 [128, 0, 0] P3 [0, 128, 0] P4 [128, 128, 0] Which I m then projecting orthographically to the screen effectively giving me two ...

Using LINQ To SQL with multiple database tables

I have an employee class with as follows: public class Employee { public string FirstName { get; set; } public string LastName { get; set; } public string UserName { get; set; } ...

Mapping points from Euclician 2-space onto a Poincare disc

For some reason it seems that everyone writing webpages about Poincare discs is only concerned with how to represent lines and measure distances. I d like to morph a collection of 2D points (as ...

Fluent NHibernate, varbinary(max) and SQLite

I have a varbinary field in my sql server database that needs to be varbinary(max). I create my database with NHibernate and I use Fluent Nhibernate for my mappings. I also use SQLite for my unit ...

Javascript redirect

I am working with javascript and here is what I am trying to do: 1. Send a get request which looks like "http://localhost:8080/myapp/verify.htm?verifyId=Agkvhs" My requests reaches my verify.jsp in ...

热门标签