Vote count:
0
I am working with legacy code. I have entity A and entity B class, but because entity b is being referenced many places, I try not to make changes on entity b. Followings are classes for these two entities. The entity B has a foreign key column which is primary key of the entity A and in the database table, the foreign key(aId) is associated with many primary key of the table b(id). What kind of changes do I need to make in entity A to get a collection of B when I query table_a using criteria? By the way, I can't create join table because entity B is a legacy code.
@Entity
@Table(name = "table_a")
public class A{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Long id;
}
@Entity
@Table(name = "table_b")
public class B{
private static final long serialVersionUID = 1L;
@Id
@Column(name="id", unique = true, nullable = false)
@GeneratedValue
private Long id;
@Column(name="table_a_id")
private Long aId;
}
asked 39 secs ago
Hibernate One-to-Many with foreign key using critera
Aucun commentaire:
Enregistrer un commentaire