2

suppose we have a class called LatLng:

public class LatLng {

    private long id;
    private double latitude;
    private double longitude;

    //setters & getters

}

as you can see in the picture below:

enter image description here

we have a one-to-one relationship between PoliceStation and LatLng

and one-to-one relationship between Hotel and LatLng

and so on...

how can we create such a relationship in hibernate? (both annotation and xml-mapping)

FaNaJ
  • 1,329
  • 1
  • 16
  • 39

1 Answers1

0

What you need is a bidirectional one-to-one association between your entities.

Check these links:

Hibernate - bidirectional @OneToOne

Hibernate bidirectional using mapping files.

Follow the links and try to create your entities.

Community
  • 1
  • 1
Chaitanya
  • 15,403
  • 35
  • 96
  • 137