0

In Hibernate 5 is it a problem if I use the same id value in different tables?

I have two entities with this annotation:

@Id
@Column(name = "ID")
public String getId()
{
     return id;
}

If I call session.get(MyClass.class, "theId") I can get the right entity?

Bacteria
  • 8,406
  • 10
  • 50
  • 67
xc93hil
  • 105
  • 1
  • 9

1 Answers1

0

Yes, you can create such mappings because

  • two classes in Java may have a field with the same name
  • two tables in database may have a column with the same name

There is nothing else to it.

Vlastimil Ovčáčík
  • 2,799
  • 27
  • 29